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

Add/Edit on the client side

1 Answer 232 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ziming
Top achievements
Rank 1
Ziming asked on 08 May 2015, 03:52 AM

Hello, I am trying to create a list of addresses in the javascript side, but so far most the examples are adding/editing to the server through ajax.

My question is, how to hook the correct event and maintain the list of addresses in JavaScript, I am trying onSave event but so far no success. below is my code

     var addresses = new kendo.data.DataSource({
        data: [
            { AddressName: "address1", UnitStreetNumber: 460, StreetName: "Church St", Suburb:"North Parramatta", State: "NSW", Postcode: "2150", Purpose: "Business", Primary: true }
        ]
    });

    $("#addressGrid").kendoGrid({
        dataSource: addresses,
        //pageable: true,
        toolbar: ["create"],
        columns: [
            { field: "AddressName", title: "Address Name", width: "120px" },
            { field: "UnitStreetNumber", title: "Unit/Street Number", width: "120px" },
            { field: "StreetName", title: "Street Name", width: "120px" },
            { field: "Suburb", title: "Suburb", width: "150px" },
            { field: "State", title: "State", width: "120px" },
            { field: "Postcode", title: "Postcode", width: "120px" },
            { field: "Purpose", title: "Purpose", width: "120px" },
            { field: "Primary", title: "Primary", width: "120px" },
            { command: ["edit", "destroy"], title: " ", width: "200px" }],
        editable: "popup",
        edit: onEdit,
        save: onSave
    });

function onSave(e) {
    // how to save it to addresses
}

1 Answer, 1 is accepted

Sort by
0
Plamen Lazarov
Telerik team
answered on 11 May 2015, 02:11 PM

Hello Ziming,

I would suggest you to include :

save:function(){
    this.refresh();
}

Click here to see the demo. Edit/Delete buttons can also be added to change the addresses.
Regards,
Plamen Lazarov
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
Ziming
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
Share this question
or