双击/单击Ext.grid.GridPanel的行

Ext.grid.GridPanel rowdblclick(单击)+ rowclick(双击)
1、双击 
var cb = new Ext.grid.RowSelectionModel({ 
     singleSelect:true //如果值是false,表明可以选择多行;否则只能选择一行 
}); 
   
var alarmGrid = new Ext.grid.GridPanel({ 
   
} 
alarmGrid.addListener('rowdblclick', rowdblclickFn); 
   
function rowdblclickFn(grid, rowindex, e){ 
     grid.getSelectionModel().each(function(rec){ 
     alert(rec.get(fieldName)); //fieldName,记录中的字段名 
     }); 
} 
   
2、单击 
var cb = new Ext.grid.RowSelectionModel({ 
     singleSelect:true //如果值是false,表明可以选择多行;否则只能选择一行 
}); 
   
var alarmGrid = new Ext.grid.GridPanel({ 
   
} 
alarmGrid.addListener('rowclick', rowclickFn); 
   
function rowclickFn(grid, rowindex, e){ 
     grid.getSelectionModel().each(function(rec){ 
     alert(rec.get(fieldName)); //fieldName,记录中的字段名 
     }); 
} 

__________

初始化是添加:

var cb = new Ext.grid.RowSelectionModel({ 
     singleSelect:true //如果值是false,表明可以选择多行;否则只能选择一行 
}); 

var alarmGrid = new Ext.grid.GridPanel({

} 
alarmGrid.addListener('rowclick', rowclickFn); 

function rowclickFn(grid, rowindex, e){ 
     grid.getSelectionModel().each(function(rec){ 
     alert(rec.get(fieldName)); //fieldName,记录中的字段名 
     }); 
} 

var grid = new Ext.grid.GridPanel({
   store: <your datastore>,
   columns:[<your columns>],
   renderTo:'example-grid',
   height:200,
   listeners:{
//单击
       rowdblclick : function(grid,row){
           alert("rowdblclick")
       },
//双击
       rowclick:function(grid,row){
           alert('rowclick')
       }
   }
});
 

你可能感兴趣的:(gridPanel)