ExtJS4.2 Grid Knowledge Point four: Change the table grid row text color, text becomes thicker across grid lines

Source: Internet
Author: User

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:

    1. Record: The currently-rendered row data Model, type: Ext.data.Model

    2. RowIndex: Number of rows currently to be rendered, type: #

    3. 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

    4. Store: Current data store, type: Ext.data.Store

    5. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.