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

RowEditEnded - page navigation

2 Answers 42 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 29 Sep 2011, 06:20 PM
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 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 04 Oct 2011, 04:18 PM
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 >>

0
Justin Lee
Top achievements
Rank 1
answered on 04 Oct 2011, 04:50 PM
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
Tags
GridView
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Justin Lee
Top achievements
Rank 1
Share this question
or