【发布时间】:2013-12-20 09:07:13
【问题描述】:
我的光滑网格设置:
var records = [];
var grid;
var columns = [
{ id: "ServerName", name: "Server Name", field: "ServerName" },
{ id: "DVCurrent", name: "DV Current", field: "DVCurrent", editor: Slick.Editors.LongText },
{ id: "DVLast", name: "DV Last", field: "DVLast" },
{ id: "PYCurrent", name: "PY Current", field: "PYCurrent", editor: Slick.Editors.LongText },
{ id: "PYLast", name: "PY Last", field: "PYLast" },
{ id: "PDCurrent", name: "PD Current", field: "PDCurrent", editor: Slick.Editors.LongText },
{ id: "PDLast", name: "PD Last", field: "PDLast" }
];
var options = {
enableCellNavigation: true,
enableColumnReorder: false,
forceFitColumns: true,
autoEdit: false,
editable: true
};
以及网格的创建:
grid = new Slick.Grid("#myGrid", records, columns, options);
从我的 MVC 控制器获取数据的函数:
function GetRecords() {
$.ajax({
url: '@VirtualPathUtility.ToAbsolute("~/Home/GetRecords")',
dataType: 'json',
type: 'GET',
success: function (data) {
records = data;
grid.setData(records);
grid.invalidate();
}
});
}
页面加载时一切顺利。数据被提取。当我单击保存按钮并且我希望网格再次更新时,就会出现问题:
$('#btnSave').click(function () {
$.ajax({
url: '@VirtualPathUtility.ToAbsolute("~/Home/UpdateAllRecords")',
dataType: 'json',
contentType: "application/json",
type: 'POST',
data: JSON.stringify(grid.getData()),
success: GetRecords
});
});
它根本没有做任何事情。该操作在服务器端成功完成,但不会刷新,就像 GetRecords 从未运行一样。没有控制台错误。
如果我重新加载页面,则会获取更新的数据。
【问题讨论】:
标签: jquery asp.net-mvc slickgrid