【问题标题】:Slickgrid update not consistentSlickgrid 更新不一致
【发布时间】: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


    【解决方案1】:

    你可能错过了这篇文章:

    // Refresh the new data rendered 
    grid1.updateRowCount();
    grid1.render();
    

    如果这不起作用,您可以尝试保存在async:false,您应该使用 firebug 检查新数据集的结果。希望对您有所帮助..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      • 2021-09-27
      • 2018-08-11
      • 2017-08-27
      • 2017-09-27
      相关资源
      最近更新 更多