extjs grid由数据的值改变行颜色
var merchantsGrid = new Ext.create("Ext.grid.Panel", {
tbar: toolbar,
store: merStore,
region: "center",
selModel: new Ext.selection.CheckboxModel(), //增加复选框
columns: [
// { text: "商家ID", dataIndex: "mer_id", sortable: true, flex: 0.5 },
{ text: "合作时间", dataIndex: "mer_cooperation", sortable: true, flex: 1 },
{ text: "缴费时间", dataIndex: "mer_paytime", sortable: true, flex: 1 },
{ text: "缴费金额", dataIndex: "mer_paymoney", sortable: true, flex: 1 },
],
viewConfig: {
forceFit: true,
sortAscText: '正序',
sortDescText: '降序',
getRowClass: function (record, rowIndex, rowParams, store) {
var curDate = new Date();
var time1 = Ext.Date.format(curDate, "Y-m-d");
var time2 = record.data.mer_paytime;
var tmpBeginTime = new Date(time1.replace(/-/g, "\/")); //时间转换
var tmpEndTime = new Date(time2.replace(/-/g, "\/")); //时间转换
for (i = 0; i < total; i++) {
if ((tmpEndTime - tmpBeginTime) / (1000 * 60 * 60 * 24) <= 3) {
return my_row_Red; // merchantsGrid.getView().getRow(gridcount).style.backgroundColor = "#ffff00";
}
}
}
},
});
var total = merchantsGrid.getStore().getCount(); //数据行数
本人想要实现 在缴费时间前3天开始,满足条件的行数改变背景颜色!!!
我做了好久都没实现,求大神帮帮忙!!
还有,一定要用for才能遍历grid吗??
------解决方案--------------------http://fineui.com/demo/#/demo/grid/grid_rowcolor.aspx
类似这个
<script type="text/javascript">
var highlightRowsClientID = '<%= highlightRows.ClientID %>';
var gridClientID = '<%= Grid1.ClientID %>';
function highlightRows() {
var highlightRows = X(highlightRowsClientID);
var grid = X(gridClientID);
grid.el.select('.x-grid3-row table.highlight').removeClass('highlight');
&nb