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

how to get the underlying record for a given row in GGC?

Hi,
I'm using gridGroupingControl to bind to a custom IList collection, and I'm displaying grouping info on the grid (group heads and footers). My question is given a row index on the grid, say row 5, how do i get the underlying record this row is bound to?
Thanks,
Frank

8 Replies

AD Administrator Syncfusion Team January 22, 2007 03:55 PM UTC

Hi Frank,

Here is a code snippet that shows how to access a record from a table given the rowindex of it.

// using the displayelements property of the grid, we can find the corresponding record.
Record r = gridGroupingControl1.Table.DisplayElements[rowindex].ParentRecord;

Best Regards,
Haneef


AD Administrator Syncfusion Team January 22, 2007 05:50 PM UTC

It works great. Thanks a lot.

>Hi Frank,

Here is a code snippet that shows how to access a record from a table given the rowindex of it.

// using the displayelements property of the grid, we can find the corresponding record.
Record r = gridGroupingControl1.Table.DisplayElements[rowindex].ParentRecord;

Best Regards,
Haneef


AD Administrator Syncfusion Team January 23, 2007 04:51 PM UTC

Now how do I do the reverse? I want to be able to find out the rowindex on the grid, given either the underlying record or the record's index on the datatable?
Thanks,
Frank

>It works great. Thanks a lot.

>Hi Frank,

Here is a code snippet that shows how to access a record from a table given the rowindex of it.

// using the displayelements property of the grid, we can find the corresponding record.
Record r = gridGroupingControl1.Table.DisplayElements[rowindex].ParentRecord;

Best Regards,
Haneef


AD Administrator Syncfusion Team January 23, 2007 05:12 PM UTC

Hi Frank,

Here is a code snippet that shows how to get the rowindex if the record is given.

int position = gridGroupingControl1.Table.DisplayElements.IndexOf(record);

Refer the Essential Grid Evalution center for more details.
http://www.syncfusion.com/support/evalcenter/default.aspx?cNode=5

Thanks,
Haneef


AD Administrator Syncfusion Team January 23, 2007 07:48 PM UTC

Hi Haneef,

Thanks for your quick reply. Actually I don't have the record; i only have the index of the record in my datasource. How can I get the rowindex based on the record index?
Thanks,

Frank

>Hi Frank,

Here is a code snippet that shows how to get the rowindex if the record is given.

int position = gridGroupingControl1.Table.DisplayElements.IndexOf(record);

Refer the Essential Grid Evalution center for more details.
http://www.syncfusion.com/support/evalcenter/default.aspx?cNode=5

Thanks,
Haneef


AD Administrator Syncfusion Team January 23, 2007 07:52 PM UTC

Hi Frank,

Please try this code snippet.

Record record = gridGroupingControl1.Table.Records[RecordIndex];
int RowIndex = gridGroupingControl1.Table.DisplayElements.IndexOf(record);

Best Regards,
Haneef


AD Administrator Syncfusion Team January 23, 2007 09:14 PM UTC

Hi Haneef,

The RecordIndex is not necessarily the index of the datarow in datatable once grouping is performed. In such case, the records on the grid will be sorted to accommodate the grouping, yet the order of the underlying datarows in the datatable remains the same. My problem is that I have the index of a datarow and I need to know which row on the grid shows that datarow.

Thanks very much,

Frank

>Hi Frank,

Please try this code snippet.

Record record = gridGroupingControl1.Table.Records[RecordIndex];
int RowIndex = gridGroupingControl1.Table.DisplayElements.IndexOf(record);

Best Regards,
Haneef


AD Administrator Syncfusion Team January 23, 2007 10:21 PM UTC

ah, i found it. it is

gridGroupingControl1.Table.UnsortedRecords[i]

Thanks very much for your help,

Frank

>Hi Haneef,

The RecordIndex is not necessarily the index of the datarow in datatable once grouping is performed. In such case, the records on the grid will be sorted to accommodate the grouping, yet the order of the underlying datarows in the datatable remains the same. My problem is that I have the index of a datarow and I need to know which row on the grid shows that datarow.

Thanks very much,

Frank

>Hi Frank,

Please try this code snippet.

Record record = gridGroupingControl1.Table.Records[RecordIndex];
int RowIndex = gridGroupingControl1.Table.DisplayElements.IndexOf(record);

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon