This is a migrated thread and some comments may be shown as answers.

Removing row breaks sorting/filtering

3 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eli
Top achievements
Rank 1
Eli asked on 01 Nov 2012, 07:31 PM
Hi,

I am using version 2012.3

I have a grid view which is autogenerating columns from a datatable. The reason I am using the RadGridView is so that the user can filter and/or sort with a minimum of hassle.

As part of the program, the user can delete rows from the table at any time. They can also add them back at a later date.

I have the add/remove working fine, basically using table.Rows.Remove(row) this triggers the AutoGeneratingColumn event for each column as the table basically reloads.

Where I am having trouble is when the user sorts or filters the data before removing a column. If the grid is sorted and you remove a column, the output shows "A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll" and the entire grid becomes blank. It does not come back if you try adding the row back.

If the user has added a filter to the grid and removes a row, it looks like it worked. The data showing is whatever you had filtered already, minus that row. The problem is that it says that there is no filter, so you cannot remove the previous filter.

How do I change the data that the grid is bound to and have the sorting/filtering update at the same time?

Thank you,

Eli

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Nov 2012, 07:36 AM
Hello,

 If your collection is INotifyCollectionChanged the grid will be updated automatically on every collection change - including item remove.

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Eli
Top achievements
Rank 1
answered on 05 Nov 2012, 09:57 PM
Once the INotifyCollectionChanged event fires, the filtering and sorting on the grid breaks.

How do I remove a row without changing the filtering or sorting?



0
Vlad
Telerik team
answered on 06 Nov 2012, 07:35 AM
Hi,

 I'm not sure I understand what exactly breaks. Can you send us small example project demonstrating your scenario and the problem?

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Eli
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Eli
Top achievements
Rank 1
Share this question
or