Deleting a row in GridGroupingControl

I am having difficulties when deleting a row from the grid. I use a checkbox to determine if a row is selected. If it is selected and I click delete I remove the row with the below code. Now if I don't persist the datatable at this point using AcceptChanges it breaks the second function below that I use to get the selected line in the grid.

e.Table.UnsortedRecords.IndexOf(gr);

This line returns the proper index in the datatable if there are no deleted rows. Once a deleted row is in the datatable it shifts all the indexes in the datatable but technically the indexes haven't changed because the datatable only has them marked to delete.

Is there a way I can get the index to the datatable without accepting changes on the datatable?

for (int i = 0; i < this.ggcDWP.Table.Records.Count; i++)
{
DataRowView drv = (DataRowView)this.ggcDWP.Table.Records[i].GetData();
DailyWeightingPatternDataSet.DWP_PARENTRow drw = (DailyWeightingPatternDataSet.DWP_PARENTRow)drv.Row;
if (bool.Parse(drw.selected.ToString()))
{
drw.selected = "False";
this.ggcDWP.Table.Records[i].Delete();
this.ggcDWP.NumberCheckedItems = 0;
}

private void ggcDWP_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if (e.Action == CurrentRecordAction.EnterRecordComplete
&& e.Record is GridRecord)
{
GridRecord gr = (GridRecord)e.Record;
int index = e.Table.UnsortedRecords.IndexOf(gr);
if (this.evntSelectionChanged != null)
this.evntSelectionChanged(index);
}
}

1 Reply

AD Administrator Syncfusion Team March 14, 2007 04:58 PM UTC

Hi Mike,

We are really sorry for the delay in responding. We have tested the mentioned issue. We could not reproduce the issue here. Could you please provide us a sample having the issue? This will help us to resolve the issue soon.

Thanks for choosing Syncfusion products.

Regards,
Haneef

Loader.
Up arrow icon