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

问题描述 投票:0回答:1

我的目标是在我的网格系统中添加选择框,并且我在下面的代码后面添加了选择框。

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

$("#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
    }]
});

所以我的目标是显示页面加载的所有数据,如果有人使用选择过滤器执行搜索,则显示执行搜索的相关数据。

php jquery jsgrid
1个回答
-1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.