【发布时间】:2026-01-13 05:50:01
【问题描述】:
根据
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:search_config
value 属性可以是对象:
If set as object it should be defined as pair value:name - editoptions:{value:{1:'One',2:'Two'}}
Json API 返回 JSON 对象
{"total":2,"page":1,"rows":[
{"Id":"L-10020","Liik":"10020","Artlnimi":"C vesinikud","Grupp":"L"},
{"Id":"L-10072","Liik":"10072","Artlnimi":"C D-Perm","Grupp":"L"}
... ] }
Artlnimi 属性值应用作搜索中的选择选项。 我尝试使用它来使用免费的 jqgrid 4.13.6 创建选择列表
$grid.jqGrid('setColProp', 'Artliik_artlnimi', {
searchoptions : {
dataUrl: 'API/ArtliikL',
buildSelect: function(response){
var tulem={ '':'All' }, res=JSON.parse(response);
$.each(res.rows, function(i, item) {
tulem[item.Artlnimi]=item.Artlnimi;
}
);
return tulem;
},
sopt: ['eq']
},
stype:"select"
});
那个错误之后
Uncaught TypeError: Cannot read property 'multiple' of undefined
at Object.success (jquery.jqgrid.src.js:9680)
at fire (jquery-1.12.4.js:3232)
at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362)
at done (jquery-1.12.4.js:9840)
at XMLHttpRequest.callback (jquery-1.12.4.js:10311)
出现在免费 jqgrid 4.13.6 源代码的第 9680 行,其中包含:
if ($select[0].multiple && $select.find("option[selected]").length === 0 && $select[0].selectedIndex !== -1) {
如何解决此问题,以便搜索元素显示来自 buildSelect 返回的对象的数据。 Ifbild select 返回包含选择元素 html 的字符串。
【问题讨论】:
标签: javascript jquery json jqgrid free-jqgrid