| View previous topic :: View next topic |
| Author |
Message |
Dennis Jelavic Power User

Joined: 13 Nov 2008 Posts: 67
|
Posted: Mon Mar 07, 2011 3:20 pm Post subject: User Entry into Grid on Dialog |
|
|
| I have inserted a grid control onto a dialog. It seems that user operations are limited to row selection. Is it possible to have a user enter data into a cell on the grid. If so How? I do not need to have the grid bound to a data table. |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Mon Mar 07, 2011 3:41 pm Post subject: |
|
|
Hello
I have never worked with a grid in a dialog but I assume they worked the same as in a data form.
The grid in a dataform is a container for the ColumnNames. you get them with
oGrid.getbyname("Name"). The ColumnNames are controls. So a gridcontrol contains more controls.
Romke |
|
| Back to top |
|
 |
Dennis Jelavic Power User

Joined: 13 Nov 2008 Posts: 67
|
Posted: Mon Mar 07, 2011 7:31 pm Post subject: |
|
|
Hi, RPG
Unfortunately they are not the same. I can get at indivuual cells from a program, but I can't find any way of setting the grid so that, when it is displayed, a user can enter data into any chosen cell. User input seems to be limited to selecting a row.
Thanks for your response anyway.
Dennis J. |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Mon Mar 07, 2011 11:18 pm Post subject: |
|
|
Hi,
Grid control is a complex control, it is not yet stable. Its API will change with CWS gridsort (released in OOo 3.4).
Currently the mouse can only select a row. _________________ Bernard
OpenOffice.org 1.1.5 fr / OpenOffice.org 3.4.1 en-US + langpacks, MS-Windows XP Home SP3
This forum is unusable, use instead Apache OpenOffice forums |
|
| Back to top |
|
 |
Dennis Jelavic Power User

Joined: 13 Nov 2008 Posts: 67
|
Posted: Mon Mar 07, 2011 11:42 pm Post subject: |
|
|
Thanks Bernard,
If anyone's interested you can set up a crude work around by settting up a number of text boxes into which a user can enter data and then on some prescribed action (eg button press) that data can be entered into the selected row of the grid. |
|
| Back to top |
|
 |
tridouble General User

Joined: 12 Dec 2004 Posts: 17
|
Posted: Sat Apr 28, 2012 2:26 am Post subject: |
|
|
It is possible.
The following python code inserts a gridcontrol in a dialog. It allows insertion, update, and deletion of records of the underlying request.
| Code: | # creation of a form
oDataForm = createUnoService ("com.sun.star.form.component.DataForm")
# database connection
oDataForm.ActiveConnection = Connection
oDataForm.CommandType = uno.getConstantByName ("com.sun.star.sdb.CommandType.COMMAND")
# define the SQL request
oDataForm.Command = "SELECT ... FROM ... WHERE"
# the form allow insert, update, delete
oDataForm.AllowInserts = True
oDataForm.AllowUpdates = True
oDataForm.AllowDeletes = True
# creation of the GridModel
oGridModel = createUnoService ( "com.sun.star.form.component.GridControl" )
# insertion of the columns in the GridModel
insCol (oGridModel, "Title1", 100, "TextField", "Col1", Field1, 1)
insCol (oGridModel, "Title2", 300, "TextField", "Col2", Field2)
...
# creation of the GridControl
oGrid = createUnoService ( "com.sun.star.form.control.GridControl" )
# coef of conversion from coord Form to coord Dialog
CX = 1.95
CY = 1.625
# position the grid
oGrid.setPosSize (X*CX, Y*CY, Width*CX, Length*CY, uno.getConstantByName ("com.sun.star.awt.PosSize.POSSIZE") )
oGrid.setModel (oGridModel)
# insertion of the Grid in the form
oDataForm.insertByName ("TheModel", oGridModel)
# insertion of the Grid in the Dialog
oDialog.addControl ("TheGrid", oGrid)
oDataForm.execute ()
#
# Possible oTypeCol :
# CheckBox, ComboBox, CurrencyField, DateField, FormattedField, ListBox,
# NumericField, PatternField, TextField, TimeField
#
def insCol (oModel, oTitle, oWidth, oTypeCol, NameCol, oField, oAlign = None):
Col = oModel.createColumn (oTypeCol)
Col.Width = oWidth
Col.Label = oTitle
Col.DataField = oField
if oAlign is not None:
Col.Align = oAlign
oModel.insertByName (NameCol, Col) |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|