Reputation: 537
I want to capture the event when someone clicks on the edit button in the grid. I am trying to call the OnEdit function, it is not working any solution for this?
<script>
// When user clicks on edit button command I would like to call this function.
function onEdit(e) {
alert('onEdit');
}
// Kendo grid code for populating the data from ajax call and edit function.
This is starting point where all events and datasource is populated.
$(document).ready(function() {
dataSource = new kendo.data.DataSource({
transport: {
update: { // Update event
type: "POST",
url: BASE_URL + "admin/updatePublisher.htm",
contentType: "application/json; charset=utf-8",
dataType: "json"
success: function (result) { // success will save the data
options.success(result);
}
},
parameterMap: function(options, operation) {
// Update is clicked or created this is place it will reach.
},
batch: true,pageSize: 50,
schema: {
type: "json",
model: {
id: "id",
fields: {
id: {
editable: false,nullable: true,type: "number"
}
}
},
data: "items" // the items return from ajax
},
}); // end of datasource
// Kendo UI
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
toolbar: [{ name: "create", text: "Add Publisher"}], // toolbar menu
columns: [{field: "publisherName"},{ command: ["edit"], title: "Actions" }],
editable: "inline"
});
});
</script>
Upvotes: 0
Views: 2076
Reputation: 537
I have found the solution to my question, hope it will be useful to someone. edit attribute in the kendoGrid is solution to my problem.
$("#grid").kendoGrid({
dataSource: dataSource,
navigatable: true,
pageable: true,
edit : function (e) {
// Write your code
},
height: 550,
toolbar: [{ name: "create", text: "Add Creater"}],
columns: [{
field: "emailCreativeName",
title: "Email Creater",
width: "350px"
},{ command: ["edit"], title: "Actions", width: "200px" }],
editable: "inline"
});
Upvotes: 1