I've been using Telerik products for a while now and have recently moved my team to using KendoUI. One big difference I noticed about grids is the change in event handlers. In this instance, I have a custom command button that should perform some kind of task like toggling an active/inactive state. It does fire the custom command's event handler as expected, but it also appears to fire the change() event.
Is this the intended behavior of the framework, or is there a way to execute a custom command without having the change() event fire as well?
Sample code:
Thank you,
-J
Is this the intended behavior of the framework, or is there a way to execute a custom command without having the change() event fire as well?
Sample code:
<script type=
"text/javascript"
>
function
OnToggleClick(e) {
e.preventDefault();
alert(
"Command has been clicked"
);
}
function
OnRowSelect(e) {
e.preventDefault();
alert(
this
.dataItem(
this
.select()).ID);
}
</script>
@{Html.Kendo().Grid<MyModel>()
.Name(
"MyGridName"
)
.DataSource(db =>
db.Ajax()
.Model(o => o.Id(x => x.ID))
.PageSize(20)
.Create(
"InsertNewRecord"
,
"Setup"
)
.Read(
"GetRecords"
,
"Setup"
)
)
.Events(ev => ev.Change(
"OnRowSelect"
))
.Columns(col =>
{
col.Bound(o => o.ID).Title(
"ID"
);
col.Bound(o => o.Field1).Title(
"Field1"
);
col.Bound(o => o.Field2).Title(
"Field2"
);
col.Bound(o => o.IsActive).Title(
"ToggleMe"
);
col.Command(com =>
{
com.Custom(
"ToggleActive"
).Text(
"Toggle"
).Click(
"OnToggleClick"
);
}).Width(80);
})
.ColumnMenu().Pageable().Filterable().Sortable().Selectable()
.Scrollable(scroll => scroll.Height(340))
.Render();
}
Thank you,
-J