In extjs grid, click the row and cell to obtain the row or cell content (data)
Js Code
Grid. addListener ('cellclick', cellclick );
Function cellclick (grid, rowIndex, columnIndex, e ){
Var record = grid. getStore (). getAt (rowIndex); // Get the Record
Var fieldName = grid. getColumnModel (). getDataIndex (columnIndex); // Get field name
Var data = record. get (fieldName );
Ext. MessageBox. alert ('show', 'currently selected data is '+ data );
}
------------------------------------------------------------------------------
Js Code
Grid. on ('mouseover', function (e) {// Add a mouseover event
Var index = grid. getView (). findRowIndex (e. getTarget (); // you can obtain the column position based on the target of the mouse.
If (index! = False) {// when the correct column is obtained (because false is returned if the input target column is not obtained)
Var record = store. getAt (index); // obtain the record of this column
Var str = Ext. encode (record. data); // assemble a string. You need to complete it yourself. Here I serialize it.
Var rowEl = Ext. get (e. getTarget (); // converts target to an Ext. Element Object.
RowEl. set ({
'Ext: qtip ': str // you can specify its tip attribute.
}, False );
}
});
---------------------------------------------------------------------------------
Js Code
Listeners :{
'Cellclick': function (grid, rowIndex, columnIndex, e ){}
}
// This event is triggered when a grid cell is clicked.
Js Code
Grid. getView (). getCell (rowIndex, columnIndex). style. background-color = "# FF6600 ";
Grid. getView (). getCell (rowIndex, columnIndex). style. color = "# FF6600"; www.2cto.com
I want to change the entire background color, not the color of words. How can I restore the color of the cell at the last vertex to the original when I click a cell ???
Refresh the table to restore the color changed by the previous click, grid. getView (). refresh (), and then change the color of the cell that you clicked this time.
Js Code
Grid. getView (). refresh ();
Grid. getView (). getCell (rowIndex, columnIndex). style. backgroundColor = "# FF9999 ";