我正在尝试使用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/