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

[Solved] Get inserted record after successful insert

3 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Travis
Top achievements
Rank 1
Travis asked on 19 Sep 2011, 07:14 PM
I'm using ajax for binding/editing my grid.  I want to do something after a new record has been successfully inserted.  Is it possible to do this?  I looked at the OnDataBound client event, but I'm not sure how to get the inserted record in this event.  I also need to do the same thing with the OnDelete event, but only if the delete was successful.

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 20 Sep 2011, 10:52 AM
Hi Travis,

Generally speaking, the grid will rebind itself after a successful insert or delete operation. There is now way however, to get the inserted / deleted records during the OnDataBound event - the grid simply "does not know" what they are.
Could you please provide more details about what exactly do you want to achieve? There is maybe a way to achieve the desired result, but we need to get a better view over your exact scenario.


Regards,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Travis
Top achievements
Rank 1
answered on 20 Sep 2011, 03:50 PM
I'm using a treeview and a couple of grids that are bound upon selection of a treeview item.  Upon inserting a record into a grid I want to append that item to the treeview without having to rebind the entire treeview.  I am a bit new to MVC so I'm not sure how to communicate with my View about the inserted record.  I tried using ViewData to store the inserted record, but it doesn't work.  The ViewData doesn't persist to the view I think because the grid is using ajax to perform its operations.  I think I could probably store the inserted record information using the OnSave client event and then if the insert was successful, use the stored information during the OnDataBind event to edit the TreeView.  It all seems a bit complicated which is why I was hoping for some kind of "OnInserted" event.
0
Travis
Top achievements
Rank 1
answered on 20 Sep 2011, 03:57 PM
It doesn't matter I guess, because the TreeView is also limited in that you cannot add nodes to the treeview using the API.  I would have to write some custom jquery script to make that modification.  I guess I will just have to rebind my entire treeview when an insert is made.  Oh joy.
Tags
Grid
Asked by
Travis
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Travis
Top achievements
Rank 1
Share this question
or