I'm trying to extend kendoGrid to a custom plugin, but have hard time figuring out what I'm doing wrong when invoking super method refresh(). I would appreciate a hint. Thanks.
(
function
(){
var
kendo = window.kendo,
ui = kendo.ui,
CHANGE =
"change"
;
var
MyGrid = ui.Grid.extend({
init:
function
(element, options) {
var
that =
this
;
ui.Grid.fn.init.call(that, element, options);
that._dataSource();
},
options: {
name:
"MyGrid"
,
autoBind:
true
},
_dataSource:
function
() {
var
that =
this
;
that.dataSource = kendo.data.DataSource.create(that.options.dataSource);
that.dataSource.bind(CHANGE,
function
() {
console.log(ui.Grid.fn);
console.log(that.dataSource);
ui.Grid.fn.refresh.call(that);
// <- problematic
});
if
(that.options.autoBind) {
that.dataSource.fetch();
}
}
});
ui.plugin(MyGrid);
})(jQuery);
$(
function
(){
$(
'#MyGrid'
).kendoMyGrid({
columns: [
{ field:
"FirstName"
, title:
"First Name"
},
{ field:
"LastName"
, title:
"Last Name"
}
],
dataSource: {
data: [
{ FirstName:
"Joe"
, LastName:
"Smith"
},
{ FirstName:
"Jane"
, LastName:
"Smith"
}
]
}
})
})