Using the official Kendo UI typescript definitions, trying to use the "grid" in the following manner refuses to compile; The error points to the toolbar property. This code works fine in normal javascript, and has never given me any trouble until I tried to use TypeScript.
this
.elements.grid = $(
'#grid'
).kendoGrid({
dataSource: {
transport: {
read: {
url:
"/administrator/data/items"
,
dataType:
"json"
,
type:
'GET'
,
cache:
false
}
},
schema: {
total:
"total"
,
data:
"data"
},
page: 0,
pageSize: 15,
take: 15,
serverPaging:
true
,
serverFiltering:
true
,
type:
"aspnetmvc-ajax"
},
toolbar: kendo.template($(
"#search-byName"
).html()),
pageable: {
refresh:
true
,
pageSizes:
true
},
selectable:
"row"
,
columns: [
{
field:
"Id"
,
width: 25,
title:
"Identity"
},
{
field:
"Name"
,
width: 40,
title:
"Name"
,
template:
"<div class='#: Quality.CSS #'>#: Name #</div><div>#: (Origin.Label != null) ? Origin.Label : '' #</div>"
}
],
change:
function
(e) {
// get the selected row from the grid
var
selected =
this
.select();
// get the data from the selected row
var
data =
this
.dataItem(selected);
// update the model
viewModel.map(data.toJSON());
// perform binding as needed
viewModel.subscribe();
// set the mode to editing, since we have
// selected an existing item
viewModel.set(
"Editing"
,
true
);
},
}).data(
"kendoGrid"
);