Example 1:
- 1. Double-click
- var cb = New Ext.grid.RowSelectionModel ({
- Singleselect:true //If the value is False, it indicates that multiple rows can be selected, otherwise only one row is selected
- });
- 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, field names in the record
- });
- }
- 2. Click
- var cb = New Ext.grid.RowSelectionModel ({
- Singleselect:true //If the value is False, it indicates that multiple rows can be selected, otherwise only one row is selected
- });
- 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, field names in the record
- });
- }
Add when initializing: The above one is written separately. Add a click-to-double event, mainly using AddListener to add ' rowclick ' and ' Rowdblclick ' for the click and double click events. And initialize the configuration, as long as the configuration grid inside the listeners can be!
Java code
- var cb = New Ext.grid.RowSelectionModel ({
- Singleselect:true //If the value is False, it indicates that multiple rows can be selected, otherwise only one row is selected
- });
- 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, field names in the record
- });
- }
- var Grid = New Ext.grid.GridPanel ({
- Store: <your Datastore>
- Columns:[<your Columns>],
- Renderto:' Example-grid ',
- Height:
- listeners:{
- Click
- Rowdblclick:function (Grid,row) {
- Alert ("Rowdblclick")
- },
- Double click
- Rowclick:function (Grid,row) {
- Alert (' Rowclick ')
- }
- }
- });
Example 2:
How does the ExtJs4.0 table double-click event be implemented?
Check out the relevant examples and Google, but the tests were unsuccessful. Please use the extjs4 of the hero to guide under, greatly appreciated!
An example attached to Google:
?
12345678910111213141516171819202122232425262728293031 |
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‘
)
}
}
});
|
Supplementary------------------------------issues
Grid.addlistener (' Itemdblclick ', click, this); function Click (Grid, rowindex, e) {alert (11);} The double-click event is Itemdbclick, and clicking the event is ItemClick.
[Go] ext Grid (EXTJS) and double click events