代码之家  ›  专栏  ›  技术社区  ›  AlexA

客户端jqGrid排序

  •  11
  • AlexA  · 技术社区  · 16 年前

    客户端

    但每次我单击排序列标题时,它 问题 Ajax对排序的调用,但我只需要使用本地数据进行就地排序。

    当前用于排序的jqGrid参数为:

    loadonce: true, // to enable sorting on client side
    sortable: true //to enable sorting
    
    3 回复  |  直到 10 年前
        1
  •  6
  •   Justin Ethier    15 年前

    为了让客户端排序正常工作,我需要打电话给 reloadGrid 加载网格后:

    loadComplete: function() {
        jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting
    }
    

    我不必在我的应用程序中的另一个网格上执行此操作,因为它被配置为使用通过另一个AJAX调用检索的数据,而不是由网格直接检索的数据:

    editurl: "clientArray"
    datatype: "local"
    
        2
  •  2
  •   Stuntbeaver    15 年前

    我在jqGrid上使用客户端排序,并在选择列表更改时检索一组新的json数据。您需要将rowTotal设置为大于或等于返回的行数,然后在重新加载网格之前将数据类型设置为“json”。

    // Select list value changed
    $('#alertType').change(function () {
            var val = $('#alertType').val();
            var newurl = '/Data/GetGridData/' + val;
            $("#list").jqGrid().setGridParam({ url: newurl, datatype: 'json' }).trigger("reloadGrid");        
    });
    
    // jqGrid setup
    $(function () {
            $("#list").jqGrid({
                url: '/Data/GetGridData/-1',
                datatype: 'json',
                rowTotal: 2000,
                autowidth: true,
                height:'500px',
                mtype: 'GET',
                loadonce: true,
                sortable:true,
                ...
                viewrecords: true,
                caption: 'Overview',
                jsonReader : { 
                    root: "rows", 
                    total: "total", 
                    repeatitems: false, 
                    id: "0"
                },
                loadtext: "Loading data...",
            });
        }); 
    
        3
  •  1
  •   László Papp    12 年前
    $(function () {
            $("#list").jqGrid({
                url: '/Data/GetGridData/-1',
                datatype: 'json',
                rowTotal: 2000,
                autowidth: true,
                height:'500px',
                mtype: 'GET',
                loadonce: true,
                sortable:true,
                ...
                viewrecords: true,
                caption: 'Overview',
                jsonReader : { 
                    root: "rows", 
                    total: "total", 
                    repeatitems: false, 
                    id: "0"
                },
                loadtext: "Loading data...",
            });
        });