OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

User Entry into Grid on Dialog

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Dennis Jelavic
Power User
Power User


Joined: 13 Nov 2008
Posts: 67

PostPosted: Mon Mar 07, 2011 3:20 pm    Post subject: User Entry into Grid on Dialog Reply with quote

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
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Mon Mar 07, 2011 3:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Dennis Jelavic
Power User
Power User


Joined: 13 Nov 2008
Posts: 67

PostPosted: Mon Mar 07, 2011 7:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Mon Mar 07, 2011 11:18 pm    Post subject: Reply with quote

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 / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
Dennis Jelavic
Power User
Power User


Joined: 13 Nov 2008
Posts: 67

PostPosted: Mon Mar 07, 2011 11:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
tridouble
General User
General User


Joined: 12 Dec 2004
Posts: 17

PostPosted: Sat Apr 28, 2012 2:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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