通过Js-grid 获取动态数据,但过滤不起作用?

dynamic data is fetched through Js-grid, but filtering is not working?

这是我的 JS 网格的 JS 代码

$(function() {

        $.ajax({
            type : "GET",
            url : "/Final/Reports?value=2016-03-03&value2=2017-03-03"
        }).done(function() {

            $("#jsGrid").jsGrid({
                height : "auto",
                width : "100%",         
                filtering: true,
                   sorting : true,
                paging : true,
                autoload : true,
                pageSize : 3,
                controller : {
                    loadData : function(filter) {
                        return $.ajax({
                            type : "GET",
                            url : "/Final/Reports?value=2016-03-03&value2=2017-03-03",
                            data : filter
                        });
                    },
                },
                fields : [ {
                    name : "patientId",
                    type : "text",
                    width : 150
                }, {
                    name : "patientName",
                    type : "text",
                    width : 150
                }, {
                    name : "genderId",
                    type : "number",
                    width : 150
                }, {
                    name : "mobile",
                    type : "number",
                    width : 150
                }, {
                    type : "control"
                } ]
            });

        });
    });

我是 JS 网格的新手,我使用 servlet 获取数据并显示在网格中。但我不知道如何过滤数据。

有什么想法吗?

Client-side filtering and server-side filtering are completely on shoulders of developer. Client-side filtering implemented in loadData method of controller. Server-side apparently implemented with server script that receives filtering parameters, and uses them to fetch data, and pass to client.

That's why you can use client-side and server-side filtering at the same time. Here is how your controller.loadData method could look like in this case:

loadData: function(filter) {
    var d = $.Deferred();

    // server-side filtering
    $.ajax({
        type: "GET",
        url: "/items",
        data: filter,
        dataType: "json"
    }).done(function(result) {
        // client-side filtering
        result = $.grep(result, function(item) {
             return item.SomeField === filter.SomeField;
        });

        d.resolve(result);
    })

    return d.promise();
}

来源问题:https://github.com/tabalinas/jsgrid/issues/32