In the ExtJS4.2 grid knowledge point one: Change table grid cell text color in the article explains how to change the color of the text in the cell, next in this chapter learn how to change the color of the entire line of text in the grid, so that you do not need to define a separate renderer function for each column, display the result slice:
650) this.width=650; "alt=" ExtJS4.2 grid knowledge Point four: Change the table grid line text color, the text becomes thicker when the grid row "src=" Http://www.itdatum.net/uploads/webui /2014/0814/20140814004.png "/>
Online Demo / Sample code
The implementation is to set the Getrowclass function of the Viewconfig property in the grid, and the function parameter list is as follows:
Record: The currently-rendered row data Model, type: Ext.data.Model
RowIndex: Number of rows currently to be rendered, type: #
Rowparams: A configuration object passed into the row template during rendering, which can be used to customize the style for the line body, which takes effect only when Enablerowbody is true
Store: Current data store, type: Ext.data.Store
Return: The returned type is: String, returning the result as the HTML code to be rendered.
Getrowclass corresponding function Changerowclass code:
function Changerowclass (record, RowIndex, Rowparams, store) {if (Record.get ("type") = = "1") {return ' X Grid-record-red '; }}
The core code is as follows:
View:UserList.js
Ext.define (' Itdatum.view.UserList ' ,{ extend: ' Ext.grid.Panel ', alias : ' widget.userlist ', title : ' all users ', store: ' Userstore ', /* getrowclass: Change row style */ viewConfig:{/*enableTextSelection:true,*/getRowClass:changeRowClass}, initcomponent: function () { this.columns = [ {header: ' Name ', dataIndex: ' name ', width:100}, {header: ' idno ', dataindex: ' Idno ', width:150}, {header: ' Gender ', dataindex: ' type ', width:60,renderer : fuNction (v) {return v==1 ? ' men ' : ' women ';}}, {header: ' Birthday ', dataindex: ' Birthday ', width:120}, {header: ' Email ', dataindex: ' Email ', flex: 1} ]; this.callparent (arguments); });
Custom style: x-grid-record-red
. x-grid-record-red {color:red;}
In addition : You can specify the style by specifying the styles. X-grid-row-over. X-grid-cell-inner to change the cell text to be thicker when the mouse is over, which must be specified . X-grid-cell-inner, Otherwise the effect is not reflected.
. x-grid-row-over. X-grid-cell-inner {font-weight:bold;}
This article is from the "itdatum" blog, make sure to keep this source http://1162235.blog.51cto.com/1152235/1540267