EXtJS grid CheckColumn,单击列/检查其状态后如何执行函数?

发布于 2024-12-10 12:57:50 字数 878 浏览 0 评论 0原文

我有带有 checkcolumn 的 ExtJS GRID,它是这样声明的:

// 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 上或在鼠标单击时添加一些侦听器。 最后 - 想要行的 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" );
   }


});

但是当我单击任何单元格时,它会触发,而不仅仅是复选框...

请帮助我

I have ExtJS GRID with checkcolumn, which is declared this way:

// 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 );
        }
      }    

    }


});

I want add some listener on changfe of it stae, or on mouse click.
Finaly - want id's of rows, where i click this column - to be stored in text field

For now i can understood how to catch click event, i use onMouseDown, this way:

// 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" );
   }


});

But it fires, when i click ANY cell, not only checkboxed ...

Pls help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡水深流 2024-12-17 12:57:50

复选框插件需要修改,之后它可以触发点击事件。

checkbox plugin need modification, after which it can fire click event.

/*
**************************************************************
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); //:)
        });
    }
}
/*
**************************************************************
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); //:)
        });
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文