Hi,
I have a Grid Grouping Control bound to 5 DataTables which are nested from level 1 though 5. The data in the grid is also displayed in tab control graphically where there is a tab for each row at the third level and the data at the 4th and 5th level are drawn on the tab page.
I want to be able to programatlically position the correct rows in the grouping grid, expanding where necessary, so that a user can select something in a particular tab page and have the coresponding row at either the 4 or 5 level positioned and selected so the user can see the coresponding data.
I have two questions:
How do I locate data in the grid using the data in the DataTable regardless of how the user may have sorted the rows at a particular level.
How do I position and select the apropriate rows in the grid so that they are visable.
Thanks for your help
WJL
AD
Administrator
Syncfusion Team
August 31, 2006 07:07 AM UTC
Hi Bill,
Issue 1:
Use the SortedColumns property in GridTableDescriptor to sort the table in a grid. Below is a code snippet
GridTableDescriptor gd = this.gridGroupingControl1.GetTableDescriptor("ChildTable");
if( !gd.SortedColumns.Contains("childID") )
gd.SortedColumns.Add("childID",ListSortDirection.Descending);
Issue 2:
To make a record as SelectedRecord, you can call the SelectedRecords.Add method. Here is a code snippet,
GridTable gt = this.gridGroupingControl1.GetTable("ChildTable");
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;
//Add the record to the selection.....
gt.SelectedRecords.Add(gt.Records[0]);
To set the record as current record, you need to call the SetCurrent() method.
gt.Records[0].SetCurrent();
Let me know if this helps.
Best Regards,
Haneef
BL
Bill Langlais
August 31, 2006 12:20 PM UTC
Hi,
Thanks for your response.
On Issue 1:
I want to find a record in the grid programatically without effecting the way the grid is sorted or apears to the user so that I can highlight it in issue 2.
>Hi Bill,
Issue 1:
Use the SortedColumns property in GridTableDescriptor to sort the table in a grid. Below is a code snippet
GridTableDescriptor gd = this.gridGroupingControl1.GetTableDescriptor("ChildTable");
if( !gd.SortedColumns.Contains("childID") )
gd.SortedColumns.Add("childID",ListSortDirection.Descending);
Issue 2:
To make a record as SelectedRecord, you can call the SelectedRecords.Add method. Here is a code snippet,
GridTable gt = this.gridGroupingControl1.GetTable("ChildTable");
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;
//Add the record to the selection.....
gt.SelectedRecords.Add(gt.Records[0]);
To set the record as current record, you need to call the SetCurrent() method.
gt.Records[0].SetCurrent();
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
September 1, 2006 07:13 AM UTC
Hi Bill,
Sorry for the inconvenience caused.
To find the record index, you can use the IndexOf method in UnsortedRecords collection. Below is a code snippet
int unsortedIndex = this.gridGroupingControl1.Table.UnsortedRecords.IndexOf(record);
int sortedIndex = this.gridGroupingControl1.Table.Records.IndexOf(record);
Thanks,
Haneef