Hi -
I am calling RemoveRange to remove rows from my grid. However, some of the rows may be hidden. RemoveRange doesn't seem to consider these rows.
For example, i have the following rows;
Row1 - visible
Row2 - hidden
Row3 - hidden
Row4 - visible
Row5 - visible
Row6 - visible
By checking a property on each row i decide Rows 1 through 3 should be removed. I call RemoveRows(1, 3). However, the rows removed are actually 1, 4 and 5.
Is there a way to remove a range of rows and have the hidden rows included in the range? We are on version 4.4.0.51
Thanks,
Julie
AD
Administrator
Syncfusion Team
February 6, 2007 11:55 PM UTC
Hi Julie,
The reason for this behavior is that, the hidden rows are not properly cleared before removing them. So, you need to call Rows.Hidden.ResetRange() to reset the rows before removing them. Please try the code snippet
this.GridControl1.Model.Rows.Hidden.ResetRange(1, 3)
this.GridControl1.Model.Rows.RemoveRange(1, 3)
Best Regards,
Haneef
JL
Julie Levy
February 7, 2007 12:44 AM UTC
Haneef -
thanks for your response. This helps, but there seems to be a refresh problem. It looks like the wrong rows are removed until i reload the grid and then everything looks fine. Is there something else i need to call to update things without reloading? Note that calling Refresh doesn't help.
Thanks,
Julie
JL
Julie Levy
February 7, 2007 12:47 AM UTC
one more bit of info: there are other hidden rows that i am not removing.
AD
Administrator
Syncfusion Team
February 7, 2007 05:09 PM UTC
Hi Julie,
Thanks for the update and for being patience. Is it possible for you to explain us more details or modify the sample, so it help us to solve your issue earlier. The following is the attachment demonstrates the RemoveRange is working fine for the sample, please let us know if you meant different scenario.
Here is a sample.
GC_Remove.zipBest regards,
Haneef
JL
Julie Levy
February 7, 2007 07:38 PM UTC
Thanks Haneef. Here is your sample updated. I've added ranges as header rows to the grid and updated what rows are hidden and then removed. Keep an eye out on row 13 which is never hidden or removed.
Julie
GC_RemoveRows.zip
AD
Administrator
Syncfusion Team
February 7, 2007 08:50 PM UTC
Hi Julie,
The reason for this behavior is that you are setting the 10th as a hidden row. After deleting the three rows(6-8) from the grid, 13th row becomes the 10th one(which is hidden).So try resetting the all hidden rows in a grid.
this.gridControl1.Model.Rows.Hidden.ResetRange(1,this.gridControl1.Model.RowCount);
this.gridControl1.Model.Rows.RemoveRange(6,8);
//set the hidden rows....here..
this.Refresh();
Best regards,
Haneef
JL
Julie Levy
February 7, 2007 09:54 PM UTC
Thanks Haneef -
I was hoping there was a way to do this without showing all of the hidden rows. It's too bad the hidden row indexes can't be updated when rows are removed from the grid. I can't really track what was hidden before the remove without reloading the grid and i am using RemoveRange to specifically avoid reloading.
Thanks for your help,
Julie
JL
Julie Levy
February 7, 2007 11:31 PM UTC
By the way, I also had a really bad refresh problem where i would load different data into the grid after having loaded data with hidden rows and there would be hidden rows even though i wasn't specifically hiding them and had cleared all the rows out before reloading. I solved this by calling this.Model.Rows.Hidden.ResetRange( 1, this.RowCount ) before clearing out all the rows (setting rowcount to 0)
Is this a bug, or how it is supposed to work? I also have to set the FrozenCount to 0 even though i have set the rowcount to 0. Is there a better way to clear out the rows in preparation for loading new data?
Thanks,
Julie
AD
Administrator
Syncfusion Team
February 7, 2007 11:45 PM UTC
Hi Julie,
Is there a better way to clear out the rows in preparation for loading new data?
>>>>>
Try calling the Model.ClearCells() method to clear the specified range of cells in a grid.
this.Grid.Model.ClearCells(GridRangeInfo.Rows(1,3),true) ;
this.Grid.Refresh();
Thanks,
Haneef
JL
Julie Levy
February 8, 2007 12:01 AM UTC
Thanks Haneef -
this actually produced even worse results for me so i'm sticking with my other approach. It seems to work for now.
Thanks again for your quick responses,
Julie