Expanding selected rows in a GDBG
I am attempting to expand rows selected in a hierarchical GDBG. I only want to expand selected rows.
I tried looping thru the GridDataBoundGrid.Selections collection and using the ExpandRowAtIndex API, but if I expand more than one row, a 'Collection Modified' exception is thrown. I am assuming this is because the number of rows changes?
Any ideas on how to tackle this?
Thanks,
Nick
I tried looping thru the GridDataBoundGrid.Selections collection and using the ExpandRowAtIndex API, but if I expand more than one row, a 'Collection Modified' exception is thrown. I am assuming this is because the number of rows changes?
Any ideas on how to tackle this?
Thanks,
Nick
SIGN IN To post a reply.
5 Replies
AD
Administrator
Syncfusion Team
January 24, 2007 11:51 PM UTC
Hi Nick,
Here is a code snippet that sshows you How to expand the selected row in a GridDataBoundGrid.
GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.SelectedRanges.CopyTo(selectedRangeList,0);
foreach(GridRangeInfo info in selectedRangeList )
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}
Please refer to the attached sample for implementation.
SelectedRowExpand.zip
Best Regards,
Haneef
Here is a code snippet that sshows you How to expand the selected row in a GridDataBoundGrid.
GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.SelectedRanges.CopyTo(selectedRangeList,0);
foreach(GridRangeInfo info in selectedRangeList )
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}
Please refer to the attached sample for implementation.
SelectedRowExpand.zip
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
January 24, 2007 11:55 PM UTC
Thanks for the quick response. I'll try this.
Thanks Haneef
Nick
Thanks Haneef
Nick
AD
Administrator
Syncfusion Team
January 25, 2007 07:24 PM UTC
This works well, except in the case where only one row is selected. SelectedRanges only seems to be valid if more than 1 row is selected. I haven't been able to find a 'SelectedRow' or 'SelectedCell' member that would work with the above solution in the case of only a single row being selected.
Any ideas?
Thanks,
Nick
Any ideas?
Thanks,
Nick
AD
Administrator
Syncfusion Team
January 25, 2007 07:44 PM UTC
Never mind, I figured it out. Using:
this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended; //Set the SelectionMode.
did the trick
Thanks!
>This works well, except in the case where only one row is selected. SelectedRanges only seems to be valid if more than 1 row is selected. I haven't been able to find a 'SelectedRow' or 'SelectedCell' member that would work with the above solution in the case of only a single row being selected.
Any ideas?
Thanks,
Nick
this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended; //Set the SelectionMode.
did the trick
Thanks!
>This works well, except in the case where only one row is selected. SelectedRanges only seems to be valid if more than 1 row is selected. I haven't been able to find a 'SelectedRow' or 'SelectedCell' member that would work with the above solution in the case of only a single row being selected.
Any ideas?
Thanks,
Nick
AD
Administrator
Syncfusion Team
January 25, 2007 08:23 PM UTC
Hi Nick,
If you are not selecting multiple cells, then SelecteRanges will not return anything. You need to use another method, GetSelectedRanges. See this KB.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=280
Here is a code snippet to expanding selected record using GetSelectedRanges method.
GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.Selections.GetSelectedRanges(out selectedRangeList,true);
foreach(GridRangeInfo info in selectedRangeList)
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}
Sample : ModifiedSelectedRowExpand.zip
Best Regards,
Haneef
If you are not selecting multiple cells, then SelecteRanges will not return anything. You need to use another method, GetSelectedRanges. See this KB.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=280
Here is a code snippet to expanding selected record using GetSelectedRanges method.
GridRangeInfoList selectedRangeList = new GridRangeInfoList();
this.gridDataBoundGrid1.Model.Selections.GetSelectedRanges(out selectedRangeList,true);
foreach(GridRangeInfo info in selectedRangeList)
{
for(int i = info.Top; i<=info.Bottom ; i++)
{
GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(i);
bool haslist = rs.HasChildList;
if(haslist)
{
bool isExpand = this.gridDataBoundGrid1.IsExpandedAtRowIndex(i);
if( !isExpand )
this.gridDataBoundGrid1.ExpandAtRowIndex(i);
}
}
}
Sample : ModifiedSelectedRowExpand.zip
Best Regards,
Haneef
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
NM Nick M
- Jan 24, 2007 11:17 PM UTC
- Jan 25, 2007 08:23 PM UTC