我在将数据加载到DevExtreme datagrid时遇到问题.如果我尝试使用此示例代码的示例:
var orders = new DevExpress.data.CustomStore({
load: function (loadOptions) {
var deferred = $.Deferred(),
args = {};
if (loadOptions.sort) {
args.orderby = loadOptions.sort[0].selector;
if (loadOptions.sort[0].desc)
args.orderby += " desc";
}
args.skip = loadOptions.skip || 0;
args.take = loadOptions.take || 12;
$.ajax({
url: "http://js.devexpress.com/Demos/WidgetsGallery/data/orderItems",
data: args,
success: function(result) {
deferred.resolve(result.items, { totalCount: result.totalCount });
},
error: function() {
deferred.reject("Data Loading Error");
},
timeout: 5000
});
return deferred.promise();
}
});
var grid = $("#gridContainer").dxDataGrid({
dataSource: {
store: orders
},
paging: {
pageSize: 12
},
pager: {
showPageSizeSelector: true,
allowedPageSizes: [8, 12, 20]
},
columns: [
"OrderNumber", "OrderDate", "StoreCity", "StoreState", "Employee", {
dataField: "SaleAmount",
format: "currency"
}
]
}).dxDataGrid("instance");
它有效,所以执行devextreme datagrid的问题我没有问题.但是,当我想将数据源设置为我的数据时,它不起作用.我有ASP.NET mvc应用程序.一项操作GetData以JSON格式返回数据.如果我将网址更改为:
网址:“ / Home / GetData”,或网址:“ localhost:port / Home / GetData /
添加:类型:“ GET”
并更改列名称以在JSON响应中命名我的列.
没用但是操作GetData以JSON格式返回数据.
我是这项技术的新手.我做错了什么吗?我没有在API参考中找到如何绑定来自MVC动作的JSON数据的信息,也许我搜索错了.
解决方法:
确保JSON中存在以下字段:
>“订单号”
>“订单日期”
>“ StoreCity”
>“ StoreState”
>“员工”
>“销售金额”