显示每页选中条目

定义全局变量var drawnArray=[];
给SelectionModel加入监听事件
var checkbox_sm=new Ext.grid.CheckboxSelectionModel({
        singleSelect: false,
             listeners : {
             rowselect :function(sm,num,record){
                 if(drawnArray.length!=0){
                     for(var i=drawnArray.length-1;i>=0;i--){
                         if(drawnArray[i].data['drawn_serialNumber'(这里的是你record里能唯一确定一条记录名,以下同此,不在做注释)]==record.get('drawn_serialNumber')){
                             continue;
                         }else{
                             if(i==0){
                                 drawnArray.push(record);
                             }
                         }
                     }
                 }else{
                     drawnArray.push(record);
                 }
             },
             rowdeselect :function(sm,num,record){
                 for(var i=drawnArray.length-1;i>=0;i--){
                     if(drawnArray[i].data['drawn_serialNumber']==record.get('drawn_serialNumber')){
                         drawnArray.splice(i,1);
                     }
                 }
             }
         }
    });
给grid的store加入监听事件
gridStore.on('datachanged', function(store) {
          var recordArray=[];
          gridStore.each(function(record) {
              for(var i=0;i<drawnArray.length;i++){
                  if(drawnArray[i].data['drawn_serialNumber']==record.get('drawn_serialNumber')){
                      recordArray.push(record)
                  }
              }
        });
        checkbox_sm.selectRecords(recordArray);
      });

你可能感兴趣的:(ext)