RowEditEnded - page navigation

3 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    170 posts
    Member since:
    Dec 2009

    Posted 29 Sep 2011 Link to this post

    I have an editable RadGrid in an SL application.  Above the SL application on the page is an html menu.  I'm using RowEditEnded to commit changes to a database. (i.e. no "Save" button)   The problem is the users are changing a cell value, and then navigating away from the page using the menu.  Since the menu isn't part of the SL application, focus doesn't leave the last cell that was edited, and the RowEditEnded event doesn't fire.

    I understand that this is not a bug, nor is it specific to Telerik controls.  However, I was wondering if anyone has every come up with a solution for this scenario?  Like using Javascript in the html to force the SL application to focus off the grid when the menu is clicked.  I don't really want to add a "Commit" button (that just removes focus from the grid).

    Thanks,
    Justin 
  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 04 Oct 2011 Link to this post

    Hello Justin Lee,

    Indeed in that situation RadGridView doesn't lost focus, therefore doesn't commit the pending edit.
    I believe that you could achieve this with some JavaScript.

    Best wishes,
    Nedyalko Nikolov
    the Telerik team

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

  3. Justin Lee
    Justin Lee avatar
    170 posts
    Member since:
    Dec 2009

    Posted 04 Oct 2011 Link to this post

    In case anyone is looking for a solution for this senario, I have been able to resolve this issue.  It isn't ideal, but it is the only solution I could come up with. 

    Basically, you register a scriptable object in the App.cs Startup method.  In the scriptable class, expose a method that checks if the grid is currently in edit mode, and if so, call CommitEdit() on the grid and return a message (like "Recent changes are in the process of being committed").  Then you call a javascript function for window.onbeforeunload (in the html).  In the function, you get the SL app object, get the scriptable object, and call the method.  If the method returns a string, then return that string in the javascript function. This will cause the browser to show the message, and prompt the user if they want to leave or not. 

    Why ask the user to stay on the page if you have already called CommittEdit?  Because when using some controls (like RadGridView), the CommitEdit will fire, but if you are calling a web service, the web service call will only fire if they choose to stay on the page. For some reason, when I did this with a regular SL grid, the web service method did fire immediately, so I didn't have to prompt the user to stay on the page.  (which I believe SL is not supposed to allow)  

    If anyone would like to see the code for this, post a reply in this thread.

    Justin
Back to Top