We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Ways to get GGC data contents per cell, per data or as a row

Hello,
How can I access data in a ggc outside of an event handler? I the following code,

ggc_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)

I can do things like

GridCurrentCell cc = e.TableControl.CurrentCell;
int rowIndex = cc.RowIndex;
int colIndex = cc.ColIndex;

etc. to get at the data. What if I don't have
GridTableControlCellClickEventArgs and just

this.ggc.TableControl... etc.

inside a method?

What are my options for accessing the grid, from the GGC object down to the individual cells?

Thanks,
Dimitri

7 Replies

AD Administrator Syncfusion Team February 21, 2007 06:21 PM UTC

First comment is that using row and column indexes in a GridGroupingControl can be problematic when you start working with nested and grouped tables. Generally, it is better to think about accessing the underlying Record objects. One collection you can use to see the records is grid.Table.FilteredRecords. This collection should correspond to the filtered, sorted list of records being displayed in the particular table. Once you have the record, you can use record.GetValue to access particular fields in the record.

But if you want to try to use row/column indexes, then one thing you can do is to use this.gridGroupingControl1.TableControl.GetTableViewStyleInfo to get the GridtableCellStyleInfo for a particular cell. Once you have that, you can access the style.TableCellIdentity which has all the information you need to know about a cell, including the DisplayElement.


AD Administrator Syncfusion Team February 21, 2007 06:38 PM UTC

Thanks Clay, but, how do I know which row in the grid is currently selected? I can't know its index and constituent cell unless I can tell where the cursor is at a given time. Is there a way to do that?





>First comment is that using row and column indexes in a GridGroupingControl can be problematic when you start working with nested and grouped tables. Generally, it is better to think about accessing the underlying Record objects. One collection you can use to see the records is grid.Table.FilteredRecords. This collection should correspond to the filtered, sorted list of records being displayed in the particular table. Once you have the record, you can use record.GetValue to access particular fields in the record.

But if you want to try to use row/column indexes, then one thing you can do is to use this.gridGroupingControl1.TableControl.GetTableViewStyleInfo to get the GridtableCellStyleInfo for a particular cell. Once you have that, you can access the style.TableCellIdentity which has all the information you need to know about a cell, including the DisplayElement.


AD Administrator Syncfusion Team February 21, 2007 06:45 PM UTC

Here is one way.

GridCurrentCell cc = grid.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);


AD Administrator Syncfusion Team February 21, 2007 07:11 PM UTC

Thanks Clay, that promises to be useful - but can I know what record is currenly selected, and the count of its cells, so that I can capture that record and save it?

something like: grid.activerecord.cell(i).text;

that would allow me to loop through the individual cells for that active record.



>Here is one way.

GridCurrentCell cc = grid.TableControl.GetNestedCurrentCell();
GridTableCellStyleInfo style = grid.TableControl.GetTableViewStyleInfo(cc.RowIndex, cc.ColIndex);


AD Administrator Syncfusion Team February 21, 2007 11:42 PM UTC

Try this code.

Record rec = gridGroupingControl1.Table.CurrentRecord;
if(rec != null)
object val = rec.GetValue("colName");


AD Administrator Syncfusion Team February 22, 2007 02:44 AM UTC

Thanks so much - I can use that in this case.

One other question. Whenever I click a row, in the grid on the left side, I get a highlighted row and trigger the TableControlCellClick event.
I can then see selected cells in bound text boxes.

However, if I use a GridFindReplaceDialogSink from a combobox, I'm able to find the combo display value and select the corresponding cell in the grid, but my combo boxes don't reflect the new row. How could I do this? In other words, duplicate the click event (I guess) but from a button/find method.

Thanks again,
Dimitri




>Try this code.

Record rec = gridGroupingControl1.Table.CurrentRecord;
if(rec != null)
object val = rec.GetValue("colName");


AD Administrator Syncfusion Team February 22, 2007 08:25 AM UTC

>>if I use a GridFindReplaceDialogSink from a combobox

I am not sure what this means. But if you want to make a particular record be the current record (& and see the triangle in the row header header), then try:

gridRecord.SetCurrent();

Loader.
Live Chat Icon For mobile
Up arrow icon