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

Save one row or save all rows

1 Answer 682 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Victor
Top achievements
Rank 1
Victor asked on 19 Aug 2015, 10:32 AM

Hello all,

 

I have a problem with save one row. Here is my code:

DataSource:

var localDataSource = new kendo.data.DataSource({
            batch: true,
            transport: {
                read: function (options) {
                    $.ajax({
                        url: "Content/JSON/GridData.json",
                        success: function (result) {
                            options.success(result);
                        },
                        error: function (result) {
                            options.error(result);
                        }
                    });
                },
 
 
                update: function (options) {
                    console.log("update call");
                    options.success();
                }
            },
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Name: "Name",
                        Position: "Position"
                    }
                }
            }
        });

 

 Kendo grid:

var grid = $("#grid").kendoGrid({
           dataSource: localDataSource,
           editable: true,
           toolbar: ["save", "cancel"],
           columns: [
             {
                 command: {
                     name: "saveOneRow", text: "save", click: function (e) {
                         var row = $(this).closest('tr');
                         grid.editRow(row);
                         grid.saveChanges(); // save all
                     }
                 }, title: " ", width: "180px"
             },
             { field: "Name", width: "100px", title: "Name" },
             { field: "Position", width: "100px", title: "Position" },
              
           ],
       }).data('kendoGrid');

 

Save all and cancel all works fine.

But how can I save one row?

(because localDataSource.sync() (save all) and localDataSource .read() (cancel all).)

 

p.s. I tried command {name: "save"}, but he didn`t fire any event

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 21 Aug 2015, 08:08 AM

Hello Victor,

I'm afraid that this is not supported. As you have already noticed, the sync method will push all of the changes/dirty records. There is no way to "sync" just individual records via the DataSource.

However, you may consider manually updating the record, for example by posting it via a AJAX request and using pushUpdate DataSource method to accept it. Here is a test page which illustrate such approach.

Regards,
Rosen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Victor
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or