0

easyUI datagrid内部编辑器加载组合框无法选择默认值

JSFiddle链接

{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;
            }
        }
    }
}
4

2 回答 2

0

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

于 2014-11-20T04:54:22.443 回答
-2

尝试将默认值设置为索引 0 而不是 1

于 2013-08-29T14:59:04.823 回答