Ext Grid listener

Grid事件-双击,单选等。  

2009-08-11 09:49:25|  分类: Extjs学习笔记 |字号 订阅

1.1   事件

1.1.1  双击事件- rowdblclick

事件名:rowdblclick

参数:function onRowDoubleClick(grid, rowIndex,e)

例如:

方法1:使用listeners的方法测试无效。

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body,

                listeners:

                {

                    "rowdblclick" : function(grid, rowIndex,e)

                    {

                        alert(grid.getStore().getAt(rowIndex).data.name);   

                    }

                }

            });

         

        });

 

方法2:用addListener的方法

 

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body

            });

            grid.addListener('rowdblclick',onRowDoubleClick);

            grid.show();

        });

       

        functiononRowDoubleClick(grid,rowIndex, e)

        {                  

          alert(grid.getStore().getAt(rowIndex).data.name);   

        }

 

1.1.2  单选事件- rowselect

事件名:rowselect

参数:function(sm, row, rec)

例如:

方法1:使用listeners的方法测试无效。

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body,

                 sm: new Ext.grid.RowSelectionModel(

              {

                   singleSelect:true,

                   listeners:

                   {

                         //单选事件

                         "rowselect":function(sm, row, rec)

                        {                  

                            Alert(rec.data.username);   

                        }            

                   });

         

        });

1.1   事件

1.1.1  双击事件- rowdblclick

事件名:rowdblclick

参数:function onRowDoubleClick(grid, rowIndex,e)

例如:

方法1:使用listeners的方法测试无效。

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body,

                listeners:

                {

                    "rowdblclick" : function(grid, rowIndex,e)

                    {

                        alert(grid.getStore().getAt(rowIndex).data.name);   

                    }

                }

            });

         

        });

 

方法2:用addListener的方法

 

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body

            });

            grid.addListener('rowdblclick',onRowDoubleClick);

            grid.show();

        });

       

        functiononRowDoubleClick(grid,rowIndex, e)

        {                  

          alert(grid.getStore().getAt(rowIndex).data.name);   

        }

 

1.1.2  单选事件- rowselect

事件名:rowselect

参数:function(sm, row, rec)

例如:

方法1:使用listeners的方法测试无效。

Ext.onReady(function ()

        {

            var  grid = new Ext.grid.GridPanel(

             {  

                autoHeight:true,

                ds: ds,           

                cm: cm,

                renderTo: document.body,

                 sm: new Ext.grid.RowSelectionModel(

              {

                   singleSelect:true,

                   listeners:

                   {

                         //单选事件

                         "rowselect":function(sm, row, rec)

                        {                  

                            Alert(rec.data.username);   

                        }            

                   });

         

        });


你可能感兴趣的:(function,ext,测试,ExtJs)