Hi,
I have a GGC that is has a datatable as a datasource. I have set a primary key column in the datasource. Now, how can I access records in the GGC by way of the primary key from the underlying datasource?
Many thanks!
HA
haneefm
Syncfusion Team
July 9, 2007 10:25 PM UTC
Hi Patrick,
You can use the Table.Records property to get the collection of sorted record elements that are children of a Table. This collection contains all records, it is not filtered. The collection provides support for determining a record's position in the grouped table using the RecordsInTableCollectionBase.IndexOf method.
[c#]
foreach( Record rec in this.grid.Table.Records)
Console.Writeline( rec.Info );
Use Table.UnsortedRecords proeprty to get the collection of unsorted Record elements that are children of a Table and represent the original records in the same order as the underlying data source. The collection provides support for determining a record's underlying position in the datasource using the UnsortedRecordsCollection.IndexOf method.
[c#]
foreach( Record rec in this.grid.Table.UnsortedRecords)
Console.Writeline( rec.Info );
Best regards,
Haneef
PC
Patrick Cheng
July 10, 2007 01:33 AM UTC
Hi Haneef,
the methods you provided assumes that i provide a record value to get the index. but what i want to accomplish is to find the record based on a primary key, which is an integer value. for example, in a datatable you can do something like
table.rows.find(key)
is there something similair with the ggc that i can implement? or would i need to just loop through each record and look for a match?
HA
haneefm
Syncfusion Team
July 10, 2007 05:10 PM UTC
Hi Patrick,
You can use the Table.PrimaryKeySortedRecords property to get the collection of primary key sorted record elements that are children of a Table. The collection provides support for determining a record in the grouped table using the FindRecord(sortKey)/ method. Below is a code snippet
this.gridGroupingControl1.Table.PrimaryKeySortedRecords.FindRecord(sortKey);
Best regards,
Haneef