因为在easyui-datagrid中要显示自己的行号,且想呈现原rownumbers列一样的背景与字体颜色,于是在网上查找了各种解决方法,综合起来见如下代码
<script type="text/javascript">
//设置列中字体的颜色,可以根据行索引row和列索index做判断
function setColumnForeColor(value, row, index)
{
return "<span style='color: black'>" + value + "</span>";
}
//设置列单元格的背景颜色,可以根据行索引row和列索index做判断
function setColumnBackColor(value, row, index)
{
return 'background-color: #efefef;';
}
</script>
<!-- 下面是两个列格式化器,styler 管背景,formatter 管字体 -->
<th field="RecNo" styler="setColumnBackColor" formatter="setColumnForeColor"></th>