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

Using save event from custom toolbar control

3 Answers 802 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shane P
Top achievements
Rank 1
Shane P asked on 21 Jan 2012, 02:04 AM
I have created a grid and I have needed to use a template to create the toolbar. I want to be able to batch edit then save back to the server.

If I weren't using a template I could simply use
  toolbar: ["create", "save", "cancel"],

To do what I need, however I need the template as I have a dropdown box in the toolbar and some other html.

How do I tap into these events from a control inside my custom toolbar?

Any help would be great!

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 Jan 2012, 10:45 AM
Hello Shane,

In order to achieve the desired functionality through Grid's API, you should use the addRow, cancelChanges and saveChanges methods. Please refer to the methods tab in this example for more details on the methods in question.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shane P
Top achievements
Rank 1
answered on 03 Feb 2012, 04:53 AM
Thanks Rosen that got me a little closer to what im trying to do.

I have hacked together some jquery to update some of the cell data and is working ok however I can't quite work out how to modify the items within the grid.
$("#apply-selected").live("click",function() {
       var dd= $("#item-selector").data("kendoDropDownList");
       var grid = $("#grid").data("kendoGrid");
       console.log(reward.value());
       if(dd.value()!='00000000-0000-0000-0000-000000000000') {
           $('#grid >tbody :checkbox').each(function() {
               if (this.checked == 1) {
                   var tr = $(this).parent().parent().parent();
                //   console.log(tr);
                   var td = tr.find(":last");
                   var dataItem = grid.dataItem(tr);
                   var model = grid.dataSource.get(dataItem.id);
                   console.log(model);
                   var h = "<span class='k-dirty'></span><div data-id=\'" + dd.value() + "'>" + dd.text() + "</div>";
                   $(tr).find("td").eq(4).html(h);
               }
           });
       }
   });

if I use the develop tools and look into my var model I can see the properties I want to update. How do I update these?

I assume if I update this and set the _modified property to true then the save event will pick up my changes? am I right?
0
Rosen
Telerik team
answered on 03 Feb 2012, 09:21 AM
Hello Shane,

In order to modify a model values you should use its set method:

var model = dataSource.get(id);
model.set("foo", "bar"); // changes model foo field's value to bar

Regards,
Rosen
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
Shane P
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Shane P
Top achievements
Rank 1
Share this question
or