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

grid not giving list of changes done at client side adding/editing/deletion - submit form with grid approach

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajesh
Top achievements
Rank 1
Rajesh asked on 18 Mar 2017, 09:10 AM
Hi All,

I am trying to submit one form having a grid in it. only example/demo so far which fits my needs is below:
sample used for posting form with grid
 
On top of that i did some small change and i am getting an issue.
Issue: 
The above given sample works fine and i can see that what ever changes were made to grid at client side, those all get posted to server when save is clicked.
but if i enable popup editing in grid, then none of items of grid data contains information on whether they were newly added or updated, same time deleted items are not coming in grid's destroyed list.

Please find attached sample(with said issue) which is exact same copy as sample with below changes:

1. enabled editing sing popup editor
2. using custom popup editor - named orderdetails

With this when i click on save, senddata js function is called but all array items which are sent to server in save ajax call are empty list. when i debugged i can see they are all empty as i am not getting dirty/isnew() giving true for added/edited rows. also grid.dataSource._destroyed.length is also 0, even after deleting few rows from grid.

Please help me solve this issue in this sample. Thanks.

Other more related query but not an issue:
In sample which i referred, list is maintained in static variable in controller, but i can't use static as that way it will be same list for all my users,
so wanted to know is there any built in support in grid where in i can just have read of datasource defined to read from db(controller action) on first load,
and then further add/update/delete happens at client side only and still it shall allow me to have popup editing enabled?
Note: I don't want to use session as unsaved data might be huge.

I am asking this as i understand if i remove update action from data source, then i can't enable editing, else grid throws error saying update is must to enable editing.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 22 Mar 2017, 07:23 AM
Hi Rajesh,

Posting the Grid data with a Form is suitable only with Batch editing, because the InLine and PopUp edit modes perform one CRUD operation at a time and after each operation a request to the controller will be made. With Batch editing you stack all operations on client-side and they will be post along with the form. 

As for the second requirement, if you need to post the Grid data with a Form, that form data could differ per user (including the data for the Grid). Nevertheless, you could use AJAX binding for the Grid and define the Read/Update/Create and Destroy action methods (so that the editing could be enabled), but since the data will be posted along with the form, you could remove the "Save Changes" button from the toolbar and use dummy action methods for the CRUD operations.


Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Rajesh
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or