Accessing data in grid control

I have set up a dialog with grid control on it. It all works well, and I am able to get a selected line returned to a variable. However, the problem begins when I start sorting by using the column headers. Other than turning the sorting feature off, is there a possibility of returning a row header value, for instance? I cannot find a solution for this anywhere.

Thank you, in advance, for any help with this.

Hello,

You state:

but you do not state just what this problem is. Please explain as it is not clear what this will do for you:

And is this actually the Row header?

@Ratslinger

Essentially what I would like to ask is if the control grid in Calc dialog is data aware, or not? In other words, when I click on a particular row, am I able to obtain just the row number, or also the data contents of the row?

Control grid has an option of sorting the data by clicking the column headers. By clicking one of those column titles, I am loosing the order in which the data was loaded into the control grid. Thus, I do not have any way of knowing which data item belongs to which row.

For now, I have disabled the sorting option [createUnoService(“com.sun.star.awt.grid.DefaultGridDataModel”)], and I’m working on sorting/filtering routines and options.

Nothing in a dialog is Data Aware. You must provide all interfacing.

For retrieving data you should have a Handler installed. I use a mousePressed event. When the event is triggered, you can get:

    sSelRow = oEvt.Source.CurrentRow
    sSelCol = oEvt.Source.CurrentColumn

You can also get the current Column:

    oControl = oDlg.getControls
    oModel = oControl(2).getModel()
    oColumn = oModel.ColumnModel.getColumns()
    oGridColumn = oColumn(oEvt.Source.CurrentColumn)

oControl(2) is my grid control here.

I then use the info in an SQL statement to retrieve other data and open a second dialog with details in a grid control in the second dialog.

Wonderful, thank you. I’ll give it a shot shortly.

@Ratslinger it did work exactly as you have stated above, thank you.