jquery - 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; }
i trying change font color of data in cell if data in greater or equal 0 text green else red
the customizetext method doesn't take 2 arguments. if open browser console see javascript errors.
in case can use 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.
Comments
Post a Comment