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

Getting invalid and valid rows (IDataErrorInfo)

1 Answer 123 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 21 Jun 2012, 07:44 AM
Hi,

I am using RadGridView to display a List of objects that implement IDataErrorInfo, this list is being populated by objects imported from an XML file. Unfortunately some of the records may contain invalid data which the application should point out. Implementing IDataErrorInfo lets me do this wonderfully.

However, I would like to find a way to get these invalid rows, and valid ones, and I have not managed to find a way to do so.

Any ideas?

Thanks,
Daryl

1 Answer, 1 is accepted

Sort by
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 21 Jun 2012, 08:16 AM
Hi,

Indeed RadGridView provides full support for IDataErrorInfo interface, but RadGridView performs data validation check only for visible items (rows). Therefore RadGridView cannot create a collection with valid and invalid rows (items). However since this interface is implemented in your data object perhaps you could store the information that an item is invalid or not. If your idea is to point out every item that is invalid you could do this by simple iteration over RadGridView.Items collection. You code should look similar to this:

foreach(var item in radGridView.Items)
{
   if ( ! item.Validate())
   {
      radGridView.ScrollIntoViewAsync(item, (f) =>
                                  {
                                      GridViewRow row = f as GridViewRow;
                                      if (row != null)
                                      {
                                           row.BeginEdit();
                                      }
                                  });
   }
}
 

Keep in mind that this code is just a pseudo code (so may not be compiled). But the idea is very simple - iterate through data items and check if the item is valid or not, then you just call ScrollIntoViewAsync and when item is in viewport, put it in edit mode (in order to correct the data). You have to repeat this process until there is no invalid items.
Let me know if this does not help.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Alan
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or