隨筆-26  評(píng)論-44  文章-20  trackbacks-0
          只要是component都可以用plugins
          plugin必須含有init方法

          使用插件:
          var checkColumn = new Ext.grid.CheckColumn({//生成一個(gè)
                 header: "Indoor?",
                 dataIndex: 'indoor',
                 width: 55
              });
          new Ext.grid.EditorGridPanel({
                  store: store,
                  cm: cm,
                  renderTo: 'editor-grid',
                  width:600,
                  height:300,
                  autoExpandColumn:'common',
                  title:'Edit Plants?',
                  frame:true,
                  plugins:checkColumn,//**********列舉要使用的插件
                  clicksToEdit:1});

           var cm = new Ext.grid.ColumnModel([{
                     id:'common',
                     header: "Common Name",
                     dataIndex: 'common',
                     width: 220,
                     editor: new fm.TextField({
                         allowBlank: false
                     })
                  },
                  checkColumn//使用插件
              ]);


          自定義插件(即自定義一個(gè)包含init()方法 的類),這里是定義一個(gè)和CheckBox類似的東西,有很多處我沒(méi)看懂
          Ext.grid.CheckColumn = function(config){
              Ext.apply(this, config);
              if(!this.id){
                  this.id = Ext.id();
              }
              this.renderer = this.renderer.createDelegate(this);
          };

          Ext.grid.CheckColumn.prototype ={
              init : function(grid){
                  this.grid = grid;
                  this.grid.on('render', function(){
                      var view = this.grid.getView();
                      view.mainBody.on('mousedown', this.onMouseDown, this);
                  }, this);
              },

              onMouseDown : function(e, t){
                  if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
                      e.stopEvent();
                      var index = this.grid.getView().findRowIndex(t);
                      var record = this.grid.store.getAt(index);
                      record.set(this.dataIndex, !record.data[this.dataIndex]);
                  }
              },

              renderer : function(v, p, record){
                  p.css += ' x-grid3-check-col-td';
                  return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'"> </div>';
              }


          posted on 2008-07-11 16:37 開機(jī) 閱讀(1434) 評(píng)論(0)  編輯  收藏 所屬分類: js

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 原阳县| 德庆县| 德惠市| 固镇县| 新巴尔虎右旗| 准格尔旗| 梁山县| 梓潼县| 浠水县| 定西市| 桑植县| 金阳县| 竹北市| 朔州市| 阿尔山市| 芜湖县| 阳曲县| 且末县| 都昌县| 文成县| 岳池县| 澄迈县| 上犹县| 桃园县| 泌阳县| 宿州市| 灵川县| 星子县| 仁化县| 舞阳县| 乌鲁木齐市| 陕西省| 沂南县| 工布江达县| 德州市| 上虞市| 建瓯市| 邛崃市| 丰宁| 内黄县| 收藏|