問題描述
easyUI datagrid內部編輯組合框無法選擇默認值 (easyUI datagrid inner edit combobox cannot selected default value)
easyUI datagrid inner editor load combobox cannot selected default value
JSFiddle link
{field: "xx", title: "xx", width: 200, editor: {
type: "combobox",
options: {
valueField: "xx",
data: [
{"xx": 1, text: "AAA", selected: true},
{"xx": 2, text: "BBB"},
{"xx": 3, text: "CCC"}
],
onLoadSuccess: function(rows) {
for(var i=0; i<rows.length; i++) {
if(rows[i].selected) {
$(this).combobox("setValue", rows[i].xx);
return;
}
}
}
}
參考解法
方法 1:
you can just try change this line
for(var i=0; i<rows.length; i++) {
to this one
for(var i=0; i<data.length; i++) {
it's tested and working.
or you can just do like this
onLoadSuccess: function(rows) {
$(this).combobox("setValue",rows[‑1].xx);
}
this will always select the first value
(by consatan、Hilarius L. Doren)