You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by Fernand Vanrie <so...@pmgroup.be> on 2012/05/16 17:43:14 UTC

How to use the SortableGridDataModel

Does anyone know to use the SortableGridDataModel  with Basic  ?

any hints are welcome

Greetz
Fernand

Re: How to use the SortableGridDataModel

Posted by Fernand Vanrie <so...@pmgroup.be>.
Tsutomu ,
Thanks a lot

I was making the Datamodel  and ColumnModel  like

   Datamodel = 
CreateUnoService("com.sun.star.awt.grid.DefaultGridDataModel")
   ColumnModel = 
CreateUnoService("com.sun.star.awt.grid.DefaultGridColumnModel")

and then adding this ellements to  the gGridModel was/is not working the 
columns are not sortable .
Using your way: Making first the GridModel and retrieving then the 
DataModel  and columnModel from it, works like a charme

Fernand



> Sub Main
>    d = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
>    dm = d.getModel()
>    gm = dm.createInstance("com.sun.star.awt.grid.UnoControlGridModel")
>    gm.setPropertyValues(_
>      array("Height", "PositionX", "PositionY", "Width"), _
>      array(100, 0, 0, 100))
>    dm.insertByName("grid", gm)
>    gm.SelectionModel = com.sun.star.view.SelectionType.MULTI
>
>    cm = gm.ColumnModel
>    c = cm.createColumn()
>    c.Title = "foo"
>    cm.addColumn(c)
>    dm = gm.GridDataModel
>    dm.addRows(array("", "", ""), array(array("c"), array("b"), array("a")))
>
>    d.execute()
>    d.dispose()
> End Sub


Re: How to use the SortableGridDataModel

Posted by Tsutomu Uchino <ha...@gmail.com>.
2012/5/17 Fernand Vanrie <so...@pmgroup.be>:
> Does anyone know to use the SortableGridDataModel  with Basic  ?
Default data model for the grid control is SortableGridDataModel now,
so you do not need to replace it with other data model instance.

Sub Main
  d = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
  dm = d.getModel()
  gm = dm.createInstance("com.sun.star.awt.grid.UnoControlGridModel")
  gm.setPropertyValues(_
    array("Height", "PositionX", "PositionY", "Width"), _
    array(100, 0, 0, 100))
  dm.insertByName("grid", gm)
  gm.SelectionModel = com.sun.star.view.SelectionType.MULTI

  cm = gm.ColumnModel
  c = cm.createColumn()
  c.Title = "foo"
  cm.addColumn(c)
  dm = gm.GridDataModel
  dm.addRows(array("", "", ""), array(array("c"), array("b"), array("a")))

  d.execute()
  d.dispose()
End Sub

Click the row header to sort existing data.
>
> any hints are welcome
>
> Greetz
> Fernand

Best,
- Tsutomu