当前位置: 代码迷 >> JavaScript >> extJS checkboxselectionmodel 默许选中
  详细解决方案

extJS checkboxselectionmodel 默许选中

热度:354   发布时间:2012-10-17 10:25:47.0
extJS checkboxselectionmodel 默认选中

var itmsDictWfxwStore = new Ext.data.Store({
         proxy: new Ext.data.HttpProxy({
             url:bocoitms_contextPath + "/dict/getAllUsedWfxw.action"
         }),
         reader: new Ext.data.JsonReader({
             root: 'data',
             id:'wfxw',
     fields:["wfxw", "wfxwMs", "wfxwlb", "wfxwlbMs"]
         }),
         remoteSort: false
     });

//加载完成所有数据后默认选中违法行为
      itmsDictWfxwStore.on('load',function(){
              var tempArray = _jtwfxwIds.split(",");
          var _arraySelected = new Array();
                 for(var i=0; i < tempArray.length; i++){
                  itmsDictWfxwStore.each(function(record){
                  if(record.data.wfxw == tempArray[i]){
         _arraySelected.push(record);
         }
                 });
   
                }
       itmsDictWfxwSM.selectRecords(_arraySelected,true);
      },this,{delay:1});//原来采用直接注册到监听里的方式,发现在数据加载完后,虽然数据已处于选中状态,但是复选框不显示√号,采用延迟(哪怕是1毫秒)后即显示,可能是extJS的bug

var itmsDictWfxwSM = new Ext.grid.CheckboxSelectionModel({
                      listeners: {
                          rowselect: function(sm, row, _record) {
             var _index = selectedWfxwStore2.getCount();
             selectedWfxwStore.insert(_index ,_record);
                          },
                          rowdeselect : function(sm, row, _record) {
             selectedWfxwStore.remove(_record);
                          }                         
                      }
                });

参考:http://fireinjava.iteye.com/blog/483922和http://www.iteye.com/problems/20024
1 楼 chenglnb 2012-05-15  
太谢谢了,解决困扰我好长时间的我一大难题,原来是个bug 
2 楼 gaoke 2012-06-08  
呵呵,共同提高,相互学习,分享是件快乐的事情
3 楼 cjl_future 2012-07-01  
非常感谢,顶顶顶,终于解决此问题了
  相关解决方案