0
使用下面的源代碼作爲模板:https://github.com/Simba-Mupfunya/Kendo-UI-SPA-Template-vs2013-MVC5如何在本MVC SPA中將kendo ui網格綁定到其數據源?
我試圖綁定其他Kendo UI控件,如網格和調度程序在javascript後面的代碼中的模型。我曾嘗試...
HTML:
<div data-role="grid"
date-scrollable="true"
data-editable="true"
data-toolbar="['create', 'save']"
data-columns="[
{ 'field': 'Name', 'width': 50 }
, { 'field': 'Phone' }
, { 'field': 'Email' }
]"
data-bind="source: contacts,
visible: isVisible,
events: {
save: onSave
}"
style="height: 200px">
</div>
JS:
define([
'text!views/contacts/contacts.html'
], function (html) {
var contactDataSource = new kendo.data.DataSource({
data: [
{ Name: "Jim Dandy", Phone: "555-1234", Email: "[email protected]" }
, { Name: "Joe Coffee", Phone: "555-1234", Email: "[email protected]" }
, { Name: "Ham Son", Phone: "555-1234", Email: "[email protected]" }
, { Name: "Dan Fooey", Phone: "555-1234", Email: "[email protected]" }
],
schema: {
model: {
fields: {
Name: { type: "string" }
, Phone: { type: "string" }
, Email: { type: "string" }
}
}
}
});
//contactDataSource.read();
var viewModel = kendo.observable({
title: 'Contacts'
, contacts: contactDataSource
});
kendo.bind(html, viewModel);
var view = new kendo.View(html, {
model: viewModel,
show: function (e) {
kendo.fx(this.element).fade('in').duration(500).play();
}
});
return view;
});
我不熟悉的劍道的視圖實現,但沒有你嘗試在視圖的show()函數中移動'kendo.bind()'?在我看來,在渲染任何東西之前你正在運行bind方法。 – Brett