添加选择框后未显示jsGrid数据

时间:2018-09-26 09:54:51

标签: php jquery jsgrid

我的目标是在网格系统中添加选择框,并成功按照以下代码添加选择框。

但是在添加选择框后,我的其他数据没有显示,当我从下拉过滤器中搜索时,它正在显示数据。

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

    filtering: true,
    editing: false,
    sorting: true,
    paging: true,
    autoload: true,
    clearFilterButton: true,

    pageSize: 10,
    pageButtonCount: 10,


    controller: {
        loadData: function(filter) {
            criteria = filter;
            var data = $.Deferred();
            $.ajax({
                type: "GET",
                contentType: "application/json; charset=utf-8",
                url: "myURL",
                dataType: "json"
            }).done(function(response) {
                var res = [];
                if (criteria.component !== "") {
                    response.forEach(function(element) {
                        if (element.component.indexOf(criteria.component) > -1) {
                            res.push(element);
                            response = res;
                        }
                    }, this);
                } else res = response;
                if (criteria.titleLong !== "") {
                    res = [];
                    response.forEach(function(element) {
                        if (element.titleLong.indexOf(criteria.titleLong) > -1)
                            res.push(element);
                    }, this);
                } else res = response;

                data.resolve(res);
            });
            return data.promise();
        }

    },

    fields: [{
        name: "component",
        type: "textarea",
        width: 150
    }, {
        name: "Id",
        type: "text",
        width: 50
    }, {
        name: "titleLong",
        type: "select",
        align: "center", // center text alignment
        autosearch: true, // triggers searching when the user changes the selected item in the filter
        items: ["", "A", "B", "C"], // an array of items for select
        valueField: "", // name of property of item to be used as value
        textField: "", // name of property of item to be used as displaying value
        selectedIndex: -1, // index of selected item by default
        valueType: "string", // the data type of the value
        readOnly: false, // a boolean defines whether select is readonly (added in v1.4)
    }, {
        name: "unit",
        type: "textarea",
        width: 150
    }, {
        name: "descr",
        type: "textarea",
        width: 150
    }]
});

因此,我的目的是在Page加载时显示所有数据,如果有人使用选择过滤器进行搜索,请向其显示与搜索相关的数据。

1 个答案:

答案 0 :(得分:-1)

可能的话,在第三个字段定义中从“ readOnly:false”中删除“,”会有所帮助。