EasyUI DataGrid 中字段 formatter 格式化不起作用


今天用 EasyUI datagrid 来做列表,要对一些数据进行格式化,判断某字段状态时,发现 formatter 格式化对应的函数不起作用。

<table id="list_data" title="未审核报表" class="easyui-datagrid" style="width: auto;height:350px;" url="" toolbar="#toolbar" pagination="true" pagesize="10" total="20" rownumbers="true" fitcolumns="true" singleselect="true" pagelist="[10,20]" loadmsg="正在努力加载数据,请稍后..."> <thead> <tr> <th data-options="field:'报表名称',width:200,align:'center'">报表名称</th> <th data-options="field:'报表分组',width:80,align:'center'">报表分组</th> <th data-options="field:'报表类型',width:80,align:'center'">报表类型</th> <th data-options="field:'报表分类',width:80,align:'center'">报表分类</th> <th data-options="field:'制表人',width:80,align:'center'">上报人</th> <th data-options="field:'实际报出日期',width:90,align:'center'" formatter="ChangeDateFormat">上报时间</th> <th data-options="field:'填报单位',width:80,align:'center'">上报单位</th> <th data-options="field:'审核状态',width:80,align:'center'">审核状态</th> <th data-options="field:'审核状态',width:80,align:'center'" formatter="managerstr">操作</th> </tr> </thead> </table>
出问题是这句: 
<th data-options="field:'审核状态',width:80,align:'center'" formatter="managerstr">操作</th>

后来检查发现 : 如果某列的 field值,在前面已经出现过,则后出现的同field列,在这里,我的是 “审核状态”,将按第一次出现的field列使用。如果第一次出现的field同值的列没有formatter,后续的formatter将无效。


处理办法,function(value,rowData,rowIndex) 第二个参数rowData.属性名访问、

function managerstr(value,rowData,rowIndex) { if (rowData["审核状态"] == "未审核") return "1"; else if (rowData["审核状态"] == "已取回重填") return "2"; else return "已经审核,不允许操作"; }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM