Hi,
I have a where i need to display data and have a button in each row, on click of the button need to toggle the record with selected property as 0 or 1.
I have used a custom command as i do not need to edit the records. and have used a click on the command, below is the code in the javascript method called in the click. But this makes the row editable and then updates the record but there is no post done to the controller, i have set the Update and Create event both. Please can you help and let me know if this is the current way of doing it.
columns.Command(command =>
{
command.Custom(
"Set"
).Click(
"onSetActive"
).HtmlAttributes(
new
{ @className =
"k-icon k-update"
, @title =
"Set"
});
command.Custom(
"Unset"
).Click(
"onUnsetActive"
).HtmlAttributes(
new
{ @className =
"k-icon k-cancel"
, @title =
"Unset"
});
}).Width(145);
......
.Create(update => update.Action("Update", "My"))
.Read(read => read.Action("Read", "My"))
.Update(update => update.Action("Update", "My"))
.Read(read => read.Action("Read", "My"))
.Update(update => update.Action("Update", "My"))
function
onSetActive(e)
{
e.preventDefault();
var
dataItem =
this
.dataItem($(e.currentTarget).closest(
"tr"
));
var
row = $(e.currentTarget).closest(
"tr"
);
var
grid = $(
"#Grid"
).data(
"kendoGrid"
);
grid.editRow(row);
dataItem.Selected = 1;
setTimeout(
function
() {
grid.saveRow();
});
}