Hello,
Is there a better way to get the grid object? Is there MVVM best practice to this approach?
HTML:
<
div
id
=
"model"
>
<
input
type
=
"button"
value
=
"ClickMe"
data-bind
=
"events:{click: onClick}"
>
<
div
id
=
"grid"
data-role
=
"grid"
data-bind
=
"source: gridDS"
data-columns="[
{ field: 'Creatives_id', title:'ID'},
{ field: 'Email', title: 'User' },
{ field: 'State' }]"></
div
>
</
div
>
JavaScript
var
model = kendo.observable({
onClick:
function
(e) {
var
grid = $(
"#grid"
).data(
"kendoGrid"
);
grid.select().each(
function
(e) {
var
dataItem = grid.dataItem(
this
);
dataItem.State = 1;
dataItem.dirty =
true
;
});
grid.refresh();
},
gridDS:
new
kendo.data.DataSource({...})
});
kendo.bind($(
"#model"
), model);
Thank you!