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

How to validate a cell with ria asyc loadoperation

1 Answer 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 23 Jan 2013, 11:20 AM
Hi,

Below scenario is what my problem.

I have a RadGridView in a silverlight page. when the user pressed AddNewItem button, the gridview will insert a row and focus to the first cell in the new row. After user input a value and pressed TAB, I need to load an item from database via RIA LoadOperation method. If the item not found in the database, the focus will not leave the first cell and show error message,if the item exists in database then assign the loaded item property to other cell and focus on next editable cell.

In my program I put the LoadOperation Code in RadGridView_CellValidating event. But the LoadOperation is asyn. call, before it return from LoadOperation, the CellValidating event finished, so that I can't validate the cell correctly.

How should I do?

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 24 Jan 2013, 03:18 PM
Hello,

Unfortunately there is no way to stop execution of the UI thread and CellValidating event. Actually System.Windows.MessageBox.Show() method stops the UI thread until "OK" or "Cancel" is pressed, but I cannot suggest you any good example how to use this.
By default RIA services handles such cases (async validation) via INotifyDataErrorInfo interface (fully supported by RadGridView). The common approach is user commits the edit, but Entity is not correct -> INotifyDataErrorInfo.ErrorsChanged is fired and RadGridView shows the error. So your goal should be to set an error of the entity or something like that when LoadOperation is finished.

All the best,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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