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

[Solved] What's the correct way to defer committing edits?

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike Bridge
Top achievements
Rank 1
Mike Bridge asked on 30 Apr 2009, 07:17 PM
I'm looking at using the RadGrid to edit an "Invoice" object which contains a List of "InvoiceItem" objects.  I want to be able to add, edit and delete these InvoiceItem objects through the RadGrid, but I also don't want the changes to be applied until the user hits "OK". 

What is the best way construct a set of objects like this with the RadGrid but defer updating the database until the end of the editing process?  Should I create a shadow DataTable or other Serializable collection and store it in the view state so I can synchronize my objects at the end of the process?  Or is there a better way of doing it?

I was initially thinking I would populate the RadGrid on PageLoad, then let the user the edits he needed, then query the RadGrid's status when the user clicks "OK" to see what all the rows contain, then apply those edits.  But because the NeedDataSource repopulates the grid with each edit, I wasn't sure what the best practice is for this situation.

Thanks!

-Mike

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 05 May 2009, 12:42 PM
Hello Mike,

There are two options for this setup.
The first is, in the case you are keeping the items open (in edit mode), and then performing a batch update. This may be similar to this approach:

http://www.telerik.com/help/aspnet-ajax/grdperformingbatchupdates.html

Alternatively, you can bind the control to a datatable stored in viewstate/session. This datatable can be synchronized at a later stage.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mike Bridge
Top achievements
Rank 1
answered on 05 May 2009, 04:08 PM
Hi Yavor,

Sounds like the batch method is the best solution for my setup---I was confused by the the DataItem not being available to the Update event handlers.

Thanks!

-Mike
Tags
Grid
Asked by
Mike Bridge
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Mike Bridge
Top achievements
Rank 1
Share this question
or