当前位置:网站首页>Ligerui table control grid changes the color of rows (cells) according to the content
Ligerui table control grid changes the color of rows (cells) according to the content
2022-07-24 16:01:00 【ZHZHK001】
ligerui Table control grid According to the State Change row / Cell Color
Methods the principle , By changing the font color of cells
//------------------------------------------------------------------------------------------
/** * Process colors according to status * @param row Row data * @param colName Column name * @param colVal The value of the column * row.colName Need to be equal to colVal * dealCol(item,"ASTATUS",item.ASTATUS) Pay attention to the quotation marks ,ASTATUS One has one without * Competent people can continue to streamline my code * @returns {*|string} */
function dealCol(row ,colName, colVal) {
//console.log(row);
if(colName == "ASTATUS"){
//1 Enable Don't deal with 0 Undefined 2 Discontinue use If this column , Return the corresponding dictionary value , And change the color
if(parseInt(row.ASTATUS) == 0){
rs = "<span style='color:blue'>" + " Undefined " + "</span>";
}else if(parseInt(row.ASTATUS) == 2){
rs = "<span style='color:red'>" + " Discontinue use " + "</span>";
}else if(parseInt(row.ASTATUS) == 1){
rs =" Enable ";
}else{
// rest
rs = "<span style='color:deepskyblue'>" + " Discontinue use " + "</span>";
}
}else{
// If not this column , Just change the color The specification of changing the color is consistent with the above column
if(parseInt(row.ASTATUS) == 0){
rs = "<span style='color:blue'>" + colVal + "</span>";
}else if(parseInt(row.ASTATUS) == 2){
rs = "<span style='color:red'>" + colVal + "</span>";
}else if(parseInt(row.ASTATUS) == 1){
rs =colVal;
}else{
// rest
rs = "<span style='color:deepskyblue'>" + colVal + "</span>";
}
}
return rs;
}
//-----------------------------------------------------------------------------------------
- Add the following code after the data in the column
, render: function(item){
return dealCol(item,"ASTATUS",item.ASTATUS); }
The following is the code of the table
s_grid = $("#id1").ligerGrid({
height: '100%'
, method: 'get'
, pageSize: 30
, checkbox: true
, isSingleCheck: true
, rownumbers: true
, autoFilter: false
, enabledEdit: false
, url: '****'
, parseData: function (res) {
return {
"Total": res.data.total,
"Rows": res.data.list
};
}
, columns: [
{
name: 'ID', width: 50, display: 'ID'} , render: function(item){
return dealCol(item,"ID",item.ID);} ,
, {
name: 'ANAME', width: 200, display: ' Card name ' , render: function(item){
return dealCol(item,"ANAME",item.ANAME);} }
, {
name: 'ANUM', width: 180, display: ' Card number ' , render: function(item){
return dealCol(item,"ANUM",item.ANUM);} }
, {
name: 'ASTATUS', width: 60 , display: ' state ', render: function(item){
return dealCol(item,"ASTATUS",item.ASTATUS); }
}
]
, toolbar: {
items: [
{
text: ' increase ', click: doNew, icon: 'add'}
]
}
});
How to change the background color of table cells , No attempt made
边栏推荐
- Can flush accounts be opened directly? Is it safe to open an account? How to open an account??
- Dynamics crm: sharing records for users and teams
- 自适应设计和响应式设计
- After taking aiyouteng's medicine, Naifei's condition improved
- Dynamics crm: how to set the order of forms
- 公钥私钥传输,以及对CA证书的理解
- 徽商期货平台安全吗?办理期货开户没问题吧?
- Withdrawal of IPO application, Yunzhou intelligent "tour" of unmanned boat enterprise fails to enter the science and Technology Innovation Board
- kubernetes GPU的困境和破局
- MySQL learning notes (summary)
猜你喜欢

Dynamics crm: mailbox configuration (III) - configure email server profiles and mailboxes

Dynamics 365: how to get the threshold value of executemullerequest in batch requests

微调LayoutLM v3进行票据数据的处理和内容识别

faster-rcnn 训练自己的数据集

Withdrawal of IPO application, Yunzhou intelligent "tour" of unmanned boat enterprise fails to enter the science and Technology Innovation Board

【LOJ3247】「USACO 2020.1 Platinum」Non-Decreasing Subsequences(DP,分治)

Dynamics crm: sharing records for users and teams

Do you understand the working principle of gyroscope?

31 next spread

There are more than 20 categories of the four operators in MySQL. It took three days and three nights to sort them out. Don't collect them quickly
随机推荐
Who is the "roll" king of the prefabricated vegetable track?
After taking aiyouteng's medicine, Naifei's condition improved
Programming in CoDeSys to realize serial communication [based on raspberry pie 4B]
[tf.keras]: a problem encountered in upgrading the version from 1.x to 2.x: invalidargumenterror: cannot assign a device for operation embedding_
2022/7/18 CF training
未来数据库需要关心的硬核创新
Host PSQL connecting virtual machine Oracle
Dynamics crm: how to set the order of forms
Code shoe set - mt2093 · palindrome digit
Database learning – select (multi table joint query) [easy to understand]
Introduction to kettle messy notes
Leetcode 223. 矩形面积
Traverse, delete, judge whether JSON data is empty, and recursion
Yolov4 trains its own data set
Deploy ZABBIX monitoring system and email alarm mechanism in lamp architecture
MySQL source code analysis -- data structure of index
Error 1053: the service did not respond to the start or control request in a timely fashion
Configuring WAPI certificate security policy for Huawei wireless devices
3、 Set foundation ArrayList set and simple student management system
电话系统规则