简体   繁体   English

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

[英]easyUI datagrid inner edit combobox cannot selected default value

easyUI datagrid inner editor load combobox cannot selected default value easyUI datagrid内部编辑器加载组合框无法选择默认值

JSFiddle link 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;
            }
        }
    }
}

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 这将始终选择第一个值

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM