首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Ext GridPanel依据条件显示复选框

2012-09-28 
Ext GridPanel根据条件显示复选框Ext GridPanel实现复选框选择框:?var selectModel new Ext.grid.Checkb

Ext GridPanel根据条件显示复选框

Ext GridPanel实现复选框选择框:

?

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

?

?但是这样每一行都会有复选框,如果需求为:某行数据的某个列满足什么条件我才有复选框选项就不太好实现了,

这样就需要重写Ext.grid.CheckboxSelectionModel的渲染,行点击涵数来实现.

?

var selectModel = new Ext.grid.CheckboxSelectionModel({      singleSelect : false,      renderer : function(v, p, record){          if (record.data['结果状态'] == '0'){               return '';          }          return '<div class="x-grid3-row-checker">&#160;</div>';      },      onHdMouseDown : function(e, t) {          if (t.className == 'x-grid3-hd-checker') {               e.stopEvent();               var hd = Ext.fly(t.parentNode);               var isChecked = hd.hasClass('x-grid3-hd-checker-on');               if (isChecked){                  hd.removeClass('x-grid3-hd-checker-on');                  this.clearSelections();              }else {                  hd.addClass('x-grid3-hd-checker-on');                  if (this.locked){                      return;                  }                  this.selections.clear();                  for (var i = 0, len = this.grid.store.getCount(); i < len; i++ ){                      if (this.grid.store.getAt(i).data["结果状态"] != '0'){                           this.selectRow(i, true);                      }                 }              }         }      },      handleMouseDown : function(g, rowIndex, e){            if (e.button !== 0 || this.isLocked()) {                   return;            }            var view = this.grid.getView();            if (e.shiftKey && !this.singleSelect && this.last != false ) {                 var last = this.last;                 this.selectRange(last, rowIndex, e.ctrlKey);                 this.last = last;                 view.focusRow(rowIndex);            }else{                 var isSelected = this.isSelected(rowIndex);                 if (e.ctrlKey && isSelected) {                      this.deselectRow(rowIndex);                 }else if(!isSelected || this.getCount() > 1){                      if(this.grid.store.getAt(rowIndex).data["结果状态"] != '0'){                          this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);                      }                      view.focusRow(rowIndex);                 }            }      }});

?

热点排行