jquery - jqGrid 不向 url 添加搜索参数

标签 jquery jqgrid

我正在尝试使用filterToolbar搜索选项。 不幸的是,带有参数的搜索字符串没有添加到 URL 中。 在调试中我看到这一行被执行:

590 if(!bsr) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); }

sd 在我的例子中是正确的。

我看到需要发送到服务器的值存储在一个名为sdata的变量中,该变量没有被发送。我还看到 postData 过滤器中包含正确的数据,但未发送。

我还注意到 $t.p.searchurl 未定义。

这是我的 jqGrid 初始化(抱歉搞砸了):

grid_options = {
                altclass: "grid-altrow",
                altRows: true,
                autowidth: true,
                beforeSelectRow: edit,
                datastr: datastr,
                datatype: datatype,
                height: "100%",
                hidegrid: false,                
                multiselect: true,
                multiselectWidth: 45,
                onPaging: do_page,
                onSortCol: sort,
                pager: "#pager",
                rowNum: ROW_NUM,
                sortname: "zone",
                url: url.toString(),
                gridComplete: grid_complete,
                jsonReader: {
                    page: page,
                    records: records,
                    repeatitems: false,
                    root: root,
                    total: total
                },
                prmNames: {
                    addoper: null,
                    deloper: null,
                    editoper: null,
                    id: null,
                    nd: null,
                    npage: null,
                    oper: null,
                    order: null,
                    page: null,
                    rows: null,
                    search: null,
                    sort: null,
                    subgridid: null,
                    totalrows: null
                },
                colNames: [
                    "Entry Id",
                    "Zone",
                    "IP Address",
                    "Netmask",
                    "Description"
                ],
                colModel: [
                    {
                        hidden: true,
                        index: "id",
                        name: "id"
                    },
                    {
                        editable: true,
                        editoptions: {
                            value: zone_map
                        },
                        edittype: "select",
                        index: "zone",
                        name: "zone"
                    },
                    {
                        editable: true,
                        editrules: {
                            required: true
                        },
                        index: "ip",
                        name: "ip"
                    },
                    {
                        editable: true,
                        editoptions: {value: netmask_edit_options_value},
                        edittype: "select",
                        index: "netmask",
                        name: "netmask",                        
                        stype: "select"
                    },
                    {
                        editable: true,
                        edittype: "custom",
                        index: "comment",
                        name: "comment"
                    }
                ]
            };
            grid.jqGrid(grid_options);              
            grid.jqGrid("filterToolbar", {
                searchOnEnter : false,
                stringResult: true,
                beforeSearch: function(e) {
                    debugger;
                }
            });

请问有什么帮助吗?

最佳答案

最终我们使用了在 serializeGridData 回发上手动序列化 postData 的解决方案(从选项中删除 stringResult: true 后)。

我不是 100% 满意,因为我们仍然不知道为什么这种情况没有按应有的方式发生,并且怀疑配置中的某些内容仍然不是 100% 正确。

所以我不接受这个答案,也许有人会做得更好:)

编辑:接受此设置,因为没有找到其他解决方案。

关于jquery - jqGrid 不向 url 添加搜索参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4843337/

相关文章:

jquery - 使用 Jquery 在 Materialize css 中选择一个特定的选项卡

javascript - 无法使用jquery获取xml元素文本值

javascript - 如何使用 jQuery 阻止内容跳到固定导航后面

jqGrid 获取所有 ID

javascript - 如何在较新版本的 free-jqgrid 中重置搜索工具栏和搜索过滤器?

jquery - 为什么 show() 只适用于使用内联 css 隐藏的字段?

jquery - FooTable 自定义切换按钮

jqgrid - 如何上传图片到jqgrid列

jquery - JSON 和 jqGrid。 "userdata"是什么?

jquery - jqgrid 将纪元日期值显示为错误日期?