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

Cancel in Inline edit mode cancels all changes

1 Answer 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kennet
Top achievements
Rank 1
Kennet asked on 16 May 2012, 09:52 AM
Hi,

Is the Cancel button in Inline edit mode really supposed to cancel all changes? If I run this code and make changes on one line and save it with the Save button and then Edit another line and click Cancel the changes in the first line aer also reverted.

<body>
    <div id="mygrid"></div>
     
    <script>
        var mydata = [
            {
                id: 1,
                name: "John"
            },
            {
                id: 2,
                name: "Stephen"
            },
            {
                id: 3,
                name: "Lisa"
            }
        ];
         
        var myDS = new kendo.data.DataSource({ data: mydata });
         
        $(document).ready(function() {
 
            //Init Grid
            var gridMagXtrReturnLines = $("#mygrid").kendoGrid({
                editable: "inline",
                navigatable: true,
                autoBind: false,
                scrollable: false,
                dataSource: myDS,
                columns: [
                    {
                        field: "id",
                        title: "ID",
                        width: 70
                    },
                    {
                        field: "name",
                        title: "Namn",
                        width: 200
                    },
                    {
                        command: ["edit"],
                        title: " "
                    }
                ]                  
            });
             
            myDS.read();
        });
     
    </script>
</body>

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 18 May 2012, 08:40 AM
Hi Kennet,

The problems is caused because the dataSource model is not defined. In order to avoid the described unexpected behaviour please define the model's id and fields:
schema: {
    model: {
        id: "id",
        fields: {
            id: { type: "number" },
            name: { type: "string" }
        }
    }           
}

For convenience I have modified your code, please check the result.


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