Sorting JsGrid排序不工作

Sorting JsGrid排序不工作,sorting,jsgrid,Sorting,Jsgrid,以下是我的JsGrid代码的一部分,我认为为了像Fiddle上的任何其他示例一样对数据进行排序,缺少了一些东西 autoload: true, inserting: false, editing: false, paging: true, pageIndex: 1, pageSize: 5, pageLoading: true, autoload: true, filter: true, sorting: true, controller: { loadData: function(fil

以下是我的JsGrid代码的一部分,我认为为了像Fiddle上的任何其他示例一样对数据进行排序,缺少了一些东西

autoload: true,
inserting: false,
editing: false,
paging: true,
pageIndex: 1,
pageSize: 5,
pageLoading: true,
autoload: true,
filter: true,
sorting: true,

controller: {
  loadData: function(filter) {
    return $.ajax({
      type: "GET",
      url: BASE_URL,
      data: filter,
      dataType: "json",
      cache: false
    });
  },
},

我尝试过排序:“数字”。

下面是基于数字的排序逻辑

$("#Grid2").jsGrid({
    height: "auto",
    width: "100%",

    filtering: false,
    editing: false,
    sorting: true,
    paging: true,
    autoload: true,
    inserting: false,
    pageSize: 15,
    pageButtonCount: 5,

    controller: {
        loadData: function(filter) {
            var d = $.Deferred();
            $.ajax({
                cache: false,
                type: 'GET',
                url: "http://" + servername + ":" + portnumber + "/api,
                data: filter,
                dataType: "json",
                success: function(data) {
                    filteredData = $.grep(data, function(item) {
                        //filtering logic
                        ;
                    });
                    d.resolve(filteredData);
                    testdata = JSON.stringify(data);
                    $("#Grid2").jsGrid("sort", 1);
                    HistoricData = data;
                },
                error: function(e) {
                    console.log(e);
                    console.log(e.responseText);
                    var errorMsg = e.responseText;
                    var msg = errorMsg + " for this particular combination";
                    showError(msg);
                    $("#displayingHistoryValues").hide();
                    $("#ExportGrid2").hide();
                    $("#Grid2").hide();
                    d.resolve();
                }
            });

            return d.promise();
        }
    },
    fields: [{
        title: "Value",
        name: "MeasureValue",
        type: "number",
        width: "5%",
        css: "custom-field",
        sorting: true,
        itemTemplate: function(value, item) {

            if (item.MeasureValue != null && item.MeasureValue != '' && item.MeasureValue.trim().length > 0) {
                var mesval = FormatValeur(item.MeasureUnit, item.MeasureValue);
                return "<div>" + mesval + "</div>";
            }

        }
    }, {
        type: "control",
        editButton: false,
        deleteButton: false,
        width: "5%"
    }]
})
$(“#Grid2”).jsGrid({
高度:“自动”,
宽度:“100%”,
过滤:假,
编辑:错,
排序:对,
是的,
自动加载:对,
插入:false,
页面大小:15,
pageButtonCount:5,
控制器:{
loadData:函数(过滤器){
var d=$.Deferred();
$.ajax({
cache:false,
键入:“GET”,
url:“http://“+servername+”:“+portnumber+”/api,
数据:过滤器,
数据类型:“json”,
成功:功能(数据){
filteredData=$.grep(数据、函数(项){
//过滤逻辑
;
});
d、 解决(过滤数据);
testdata=JSON.stringify(数据);
$(“#Grid2”).jsGrid(“sort”,1);
历史数据=数据;
},
错误:函数(e){
控制台日志(e);
console.log(如responseText);
var errorMsg=e.responseText;
var msg=errorMsg+“用于此特定组合”;
味精;
$(“#显示历史值”).hide();
$(“#ExportGrid2”).hide();
$(“#Grid2”).hide();
d、 解决();
}
});
返回d.promise();
}
},
字段:[{
标题:“价值”,
名称:“度量值”,
键入:“数字”,
宽度:“5%”,
css:“自定义字段”,
排序:对,
itemTemplate:函数(值、项){
如果(item.MeasureValue!=null&&item.MeasureValue!=''&&item.MeasureValue.trim().length>0){
var mesval=FormatValeur(item.MeasureUnit,item.MeasureValue);
返回“+mesval+”;
}
}
}, {
类型:“控制”,
编辑按钮:错误,
deleteButton:false,
宽度:“5%”
}]
})