How to validate a cell with ria asyc loadoperation

2 posts, 0 answers
  1. Eric
    Eric avatar
    3 posts
    Member since:
    Aug 2012

    Posted 23 Jan 2013 Link to this post


    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?
  2. Nedyalko Nikolov
    Nedyalko Nikolov avatar
    871 posts

    Posted 24 Jan 2013 Link to this post


    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.

Back to Top