2011-10-15 41 views
0

我有ExtJS的網格checkcolumn,該聲明是這樣的:EXtJS grid CheckColumn,單擊列後如何執行函數/檢查其狀態?

// the check column is created using a custom plugin 
sel_column = new Ext.grid.CheckColumn({ 
    sortable: false, 
    header: 'STE<br />SEL', 
    dataIndex: 'sel', 
    width: field_w, 

    listeners: 
    { 

     "mousedown": 
     { 
     fn : function(e) 
     {  
      $.log("Sel cellclick" , e); 
     } 
     }  

    } 


}); 

我想加上changfe一些聽衆的它stae,或點擊鼠標。 Finaly - 要行,其中我點擊此列的ID的 - 要存儲在文本字段

現在我可以理解如何捕捉單擊事件,我使用onmousedown事件,像這樣:

// the check column is created using a custom plugin 
sel_column = new Ext.grid.CheckColumn({ 
    sortable: false, 
    header: 'STE<br />SEL', 
    dataIndex: 'sel', 
    width: field_w, 

    onMouseDown: function(e) 
    { 
    $.log(e,"MouseDown"); 
    } 


}); 

但它觸發,當我點擊任一單元格,不僅checkboxed ...

請幫助我

回答

0

複選框插件需要修改後,它可以觸發點擊事件。

+0

寫在這裏的意見,如果你需要解決方案... –

0
/* 
************************************************************** 
Sample to add event 'checkchange' in checkbox on checkcolumn, 
works with ExtJS 4 or above 
*/ 
//Add you checkcolumn id:'op_check'. No need separate plugin. 
//Put this code in You Grid 

listeners:{ 
    afterrender:function(){ 
     g = this; //This grid 
     Ext.getCmp('op_check').on('checkchange', function(c, i){ 
      //Get id from row/record (if in store exist field 'id') 
      //"i" - in this function is index row, where clicked checkbox 
      rec = g.store.getAt(i); 
      id = rec.get('id'); 
      console.log(id); //:) 
     }); 
    } 
} 
+0

如何得到行/記錄的id,這個複選框在哪裏? –

+0

我更改了示例,請參閱... – clichok