2013-07-25 35 views
0

easyUI數據網格內編輯負荷組合框不能選擇默認值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; 
      } 
     } 
    } 
} 

回答

-2

嘗試把默認值索引0而不是1

0

你可以試試改這條線

for(var i=0; i<rows.length; i++) { 

to t他的一個

for(var i=0; i<data.length; i++) { 

它的測試和工作。

,或者你可以做這樣的

onLoadSuccess: function(rows) { 

     $(this).combobox("setValue",rows[-1].xx); 

} 

這將始終選擇第一個值