我正在尝试将 Kendo UI Grid 与 Durandal 2.0.1 一起使用,但 API 调用未发送且 Grid 根本没有出现,请让我知道我做错了什么。
我已按照 Durandal Docs 的建议实施
主.js
requirejs.config({
paths: {
'text': '../Scripts/text',
'durandal': '../Scripts/durandal',
'plugins': '../Scripts/durandal/plugins',
'transitions': '../Scripts/durandal/transitions'
}
});
define('jquery', function() { return jQuery; });
define('knockout', ko);
define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'durandal/binder'], function (system, app, viewLocator, binder) {
//>>excludeStart("build", true);
system.debug(true);
//>>excludeEnd("build");
app.title = 'Durandal Starter Kit';
app.configurePlugins({
router: true,
dialog: true,
widget: true
});
app.start().then(function() {
//Replace 'viewmodels' in the moduleId with 'views' to locate the view.
//Look for partial views in a 'views' folder in the root.
viewLocator.useConvention();
// As per http://durandaljs.com/documentation/KendoUI/
kendo.ns = "kendo-";
binder.binding = function (obj, view) {
kendo.bind(view, obj.viewModel || obj);
};
//Show the app by setting the root view model for our application with a transition.
app.setRoot('viewmodels/shell', 'entrance');
});
});
欢迎.js
define(function() {
var vm = {
displayName: 'Roles',
gridOptions:{
dataSource: roleDataSource,
height: 700,
toolbar: [{ name: "create", text: "Add New Role" }],
columns: [
{ field: "Name", title: "Name" },
{ field: "Description", title: "Description" },
{ field: "Key", title: "Key" }
],
}
};
return vm;
var roleDataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http://tvaiswb01/api/role/GetRoles",
dataType: "json"
},
parameterMap: function (data, operation) {
return JSON.stringify(data);
}
},
batch: false,
error: error,
pageSize: 20,
requestEnd: roleDataSource_requestEnd,
schema: {
model: {
id: "Id",
fields: {
Id: { editable: false, nullable: true },
Name: { validation: { required: true } },
Description: { validation: { required: false } },
Key: { validation: { required: false } },
}
}
}
});
});
欢迎.html
<section>
<h2 data-bind="html:displayName"></h2>
<div data-kendo-bind="kendoGrid: gridOptions" id="roleGrid"></div>
</section>