extjs grid使用总结

版本:3.2.1,主要使用在BannerAdmin上:

1:使用store要注意:
一般使用record.beginEdit, set,endEdit,---(update event)-->commit/reject的步骤来更新/还原数据,直接修改record的data的值不会触发update等事件,估计这样的话reject也不会起作用。
2:EditGrid的默认selmode是CellSelectModel.CheckColumn是在ux包里面的。发现直接修改CheckColumn绑定的record.data后,会反映在CheckColumn上。
3:EditGrid要支持拖拽的话,还要改代码:[见cm.js]
Ext.override(Ext.grid.GridPanel, {
               getDragDropText : function() {
                   var sm = this.selModel;

                   var count;
                   if (sm instanceof Ext.grid.CellSelectionModel) {
                       count = 1;
                   } else {
                       count = sm.getCount();
                   }
                   return String.format(this.ddText, count, count == 1
                                   ? ''
                                   : 's');
               }
           });
   Ext.override(Ext.grid.GridDragZone, {
               getDragData : function(e) {
                   var t = Ext.lib.Event.getTarget(e);
                   var rowIndex = this.view.findRowIndex(t);
                   var cellIndex = this.view.findCellIndex(t);

                   if (rowIndex !== false) {
                       var sm = this.grid.selModel;

                       // RowSelectionModel
                       if (sm instanceof Ext.grid.RowSelectionModel) {
                           if (!sm.isSelected(rowIndex) || e.hasModifier()) {
                               sm.handleMouseDown(this.grid, rowIndex, e);
                           }
                           return {
                               grid : this.grid,
                               ddel : this.ddel,
                               rowIndex : rowIndex,
                               selections : sm.getSelections()
                           };
                       }

                       // CellSelectionModel
                       if (sm instanceof Ext.grid.CellSelectionModel) {
                           sel = sm.getSelectedCell();

                           rowAlreadySelected = sel && sel[0] == rowIndex;

                           if (!rowAlreadySelected || e.hasModifier()) {
                               sm.handleMouseDown(this.grid, rowIndex,
                                       cellIndex, e);
                           }

                           store = this.grid.getStore();
                           sel = sm.getSelectedCell();
                           if (sel)
                               return {
                                   grid : this.grid,
                                   ddel : this.ddel,
                                   rowIndex : rowIndex,
                                   selections : [store.getAt(sel[0])]
                               };
                           else
                               return {
                                   grid : this.grid,
                                   ddel : this.ddel,
                                   rowIndex : rowIndex,
                                   selections : []
                               };
                       }
                   }
                   return false;

               }
           });


Total views.

© 2013 - 2018. All rights reserved.

Powered by Hydejack v6.6.1