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

[Solved] Modifying Grid bound to local data wont set dirty flag

1 Answer 462 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 1
Kris asked on 29 Dec 2014, 09:32 PM
Hi,

I have a grid which is bound to local JavaScript array. When i modify few records and try to get list of them, by checking "dirty" flag, i get nothing. Same when i try to retrieve deleted records; grid.dataSource._destroyed is empty.

var gridData = [
    { Id: 1, PaymentDate: '1/1/2015', Amount: 100 },
    { Id: 2, PaymentDate: '2/1/2015', Amount: 200 },
    { Id: 3, PaymentDate: '3/1/2015', Amount: 300 },
    { Id: 4, PaymentDate: '4/1/2015', Amount: 400 },
];
 
$(function() {
    $("#grid").kendoGrid({
        dataSource: {
            data: gridData,
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Id: { type: "number" },
                        PaymentDate: { type: "date" },
                        Amount: { type: "number" }
                    }
                },
            }
        },
        editable: {
            mode: "inline"
        },
        toolbar: ["create", "save", "cancel"],
        columns: [
            {
                field: "Id",
                title: "Id",
                width: "150px"
            },
            {
                field: "PaymentDate",
                title: "Payment Date",
                format: "{0:" + dateFormat + "}",
                width: "150px"
            },
            {
                field: "Amount",
                title: "Amount",
                format: "{0:c}",
                width: "150px"
            },
            {
                command: ["edit", "destroy"]
            }
        ]
    });
 
    grid = $("#grid").data("kendoGrid");
})
 
function show() {
    var data = grid.dataSource.data();
    var destroyed = grid.dataSource._destroyed;
 
    for (i = 0; i < data.length; i++) {
        if (data[i].dirty) {
            console.log(data[i].Id);
        }
    }
 
    for (i = 0; i < destroyed.length; i++) {
        console.log(destroyed[i].Id);
    }
}


Please suggest how i may do this.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Dec 2014, 02:31 PM
Hello,

This happens because inline editing automatically syncs the changes which in the case of local transport are automatically accepted hence no dirty flag. You could either use in cell edit mode or create a custom transport like this: http://dojo.telerik.com/@korchev/URaju


Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Kris
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or