customizeText devextreme not working
datagrid = $("#gridContainer").dxDataGrid({
columns: [{
dataField: "STCG",
caption: "STCG",
format: 'fixedPoint',
allowFiltering: false,
precision: 2,
customizeText: function(cellElement, cellInfo) {
var fieldData = cellInfo.value;
if (fieldData >= 0) {
cellInfo.cellElement.addClass("greencolortext");
} else {
cellInfo.cellElement.addClass("redcolortext");
}
}
}]
}).dxDataGrid("instance");
.greencolortext {
color: #2DC48D;
}
.redcolortext {
color: #bf4e6a;
}
The customizeText method doesn't take 2 arguments. Well if you open browser console you will see javascript errors.
In your case you can use the cellTemplate option:
cellTemplate: function($cell, cellInfo) {
var fieldData = cellInfo.data.STCG;
if (fieldData >= 0) {
$cell.addClass("greencolortext");
} else {
$cell.addClass("redcolortext");
}
$cell.append(cellInfo.text);
}
Demo.
Refer this - dxDataGrid - customizeText does not change cell text under certain conditions
The customizeText callback function is intended for changing the cell text. If you wish to completely customize your cell content, use only cellTemplate.
Hope this help..
链接地址: http://www.djcxy.com/p/5242.html