日期:2014-05-16  浏览次数:20353 次

Extjs中formPanel加载数据时怎么让Checkbox根据值自动选中
我用的是load方法,
success : function(form,action) {
    var repair = action.result.data.repair;
   if(repair == "X"){
       itemForm.findById("repair").setValue(true);
   }
   var overhaul = action.result.data.overhaul;
   if(overhaul == 'X'){
       itemForm.findById("overhaul").setValue(true);
   }
}

通过action.result.data.repair取到json中repair对应的值。
itemForm.findById("repair").setValue(true);就可以使Checkbox设置为选中。
千万不能这样使用:
itemForm.findById("repair").checked=true可以把repair的值改为true但是不能在页面上显示选中状态