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

          使用插件:
          var checkColumn = new Ext.grid.CheckColumn({//生成一個
                 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//使用插件
              ]);


          自定義插件(即自定義一個包含init()方法 的類),這里是定義一個和CheckBox類似的東西,有很多處我沒看懂
          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 開機 閱讀(1440) 評論(0)  編輯  收藏 所屬分類: js

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 景东| 中牟县| 普陀区| 安丘市| 汉源县| 静乐县| 江北区| 尼玛县| 海城市| 即墨市| 溆浦县| 许昌县| 米易县| 深泽县| 凉城县| 阿城市| 绍兴市| 洪湖市| 缙云县| 大埔县| 湛江市| 吉安市| 凤城市| 沙坪坝区| 封开县| 嘉善县| 特克斯县| 南溪县| 讷河市| 沙坪坝区| 阜平县| 康定县| 泊头市| 桦南县| 天水市| 泗洪县| 郁南县| 湄潭县| 金平| 崇文区| 报价|