海水正藍(lán)

          面朝大海,春暖花開
          posts - 145, comments - 29, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
          Ext GridPanel實(shí)現(xiàn)復(fù)選框選擇框:

          1 var selectModel = new Ext.grid.CheckboxSelectionModel({
          2     singleSelect : false
          3 });
          4 

           但是這樣每一行都會(huì)有復(fù)選框,如果需求為:某行數(shù)據(jù)的某個(gè)列滿足什么條件我才有復(fù)選框選項(xiàng)就不太好實(shí)現(xiàn)了,

          這樣就需要重寫Ext.grid.CheckboxSelectionModel的渲染,行點(diǎn)擊涵數(shù)來實(shí)現(xiàn).

           1 var selectModel = new Ext.grid.CheckboxSelectionModel({
           2       singleSelect : false,
           3       renderer : function(v, p, record){
           4           if (record.data['結(jié)果狀態(tài)'] == '0'){
           5                return '';
           6           }
           7           return '<div class="x-grid3-row-checker">&#160;</div>';
           8       },
           9       onHdMouseDown : function(e, t) {
          10           if (t.className == 'x-grid3-hd-checker') {
          11                e.stopEvent();
          12                var hd = Ext.fly(t.parentNode);
          13                var isChecked = hd.hasClass('x-grid3-hd-checker-on');
          14                if (isChecked){
          15                   hd.removeClass('x-grid3-hd-checker-on');
          16                   this.clearSelections();
          17               }else {
          18                   hd.addClass('x-grid3-hd-checker-on');
          19                   if (this.locked){
          20                       return;
          21                   }
          22                   this.selections.clear();
          23                   for (var i = 0, len = this.grid.store.getCount(); i < len; i++ ){
          24                       if (this.grid.store.getAt(i).data["結(jié)果狀態(tài)"!= '0'){
          25                            this.selectRow(i, true);
          26                       }
          27                  }
          28               }
          29          }
          30       },
          31       handleMouseDown : function(g, rowIndex, e){
          32             if (e.button !== 0 || this.isLocked()) {
          33                    return;
          34             }
          35             var view = this.grid.getView();
          36             if (e.shiftKey && !this.singleSelect && this.last != false ) {
          37                  var last = this.last;
          38                  this.selectRange(last, rowIndex, e.ctrlKey);
          39                  this.last = last;
          40                  view.focusRow(rowIndex);
          41             }else{
          42                  var isSelected = this.isSelected(rowIndex);
          43                  if (e.ctrlKey && isSelected) {
          44                       this.deselectRow(rowIndex);
          45                  }else if(!isSelected || this.getCount() > 1){
          46                       if(this.grid.store.getAt(rowIndex).data["結(jié)果狀態(tài)"!= '0'){
          47                           this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);
          48                       }
          49                       view.focusRow(rowIndex);
          50                  }
          51             }
          52       }
          53 });
          原文:
          http://fordream.iteye.com/blog/1179252



          主站蜘蛛池模板: 淮阳县| 育儿| 延长县| 大洼县| 沾化县| 永春县| 镇安县| 章丘市| 武定县| 松桃| 仁怀市| 灵石县| 兴化市| 凤台县| 拜泉县| 英德市| 芒康县| 察隅县| 中山市| 西林县| 衡山县| 集贤县| 楚雄市| 弋阳县| 宜黄县| 深泽县| 札达县| 额济纳旗| 乌拉特中旗| 新邵县| 彰武县| 汨罗市| 谢通门县| 榆树市| 丹江口市| 论坛| 娄烦县| 泰安市| 清丰县| 长宁县| 开远市|