生活随笔
收集整理的這篇文章主要介紹了
EasyUI DataGrid 中字段 formatter 格式化不起作用
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
今天用 EasyUI datagrid 來做列表,要對一些數(shù)據(jù)進(jìn)行格式化,推斷某字段狀態(tài)時(shí),發(fā)現(xiàn) formatter 格式化相應(yīng)的函數(shù)不起作用。
<table id="list_data" title="未審核報(bào)表" 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="正在努力載入數(shù)據(jù),請稍后..."><thead><tr><th data-options="field:'報(bào)表名稱',width:200,align:'center'">報(bào)表名稱</th><th data-options="field:'報(bào)表分組',width:80,align:'center'">報(bào)表分組</th><th data-options="field:'報(bào)表類型',width:80,align:'center'">報(bào)表類型</th><th data-options="field:'報(bào)表分類',width:80,align:'center'">報(bào)表分類</th><th data-options="field:'制表人',width:80,align:'center'">上報(bào)人</th><th data-options="field:'實(shí)際報(bào)出日期',width:90,align:'center'" formatter="ChangeDateFormat">上報(bào)時(shí)間</th><th data-options="field:'填報(bào)單位',width:80,align:'center'">上報(bào)單位</th><th data-options="field:'審核狀態(tài)',width:80,align:'center'">審核狀態(tài)</th><th data-options="field:'審核狀態(tài)',width:80,align:'center'" formatter="managerstr">操作</th></tr></thead>
</table>
出問題是這句:
<th data-options="field:'審核狀態(tài)',width:80,align:'center'" formatter="managerstr">操作</th>
改成,前面沒有出現(xiàn)過的字段,否則,不會(huì)進(jìn)來格式化的。
<th data-options="field:'用戶報(bào)表編號',width:80,align:'center'" formatter="managerstr">操作</th>
后來檢查發(fā)現(xiàn) : 假設(shè)某列的 field值,在前面已經(jīng)出現(xiàn)過,則后出現(xiàn)的同field列,在這里,我的是 “審核狀態(tài)”,將按第一次出現(xiàn)的field列使用。假設(shè)第一次出現(xiàn)的field同值的列沒有formatter,興許的formatter將無效。
function managerstr(value,rowData,rowIndex) {if (rowData["審核狀態(tài)"] == "未審核")return "1";else if (rowData["審核狀態(tài)"] == "已取回重填")return "2";elsereturn "已經(jīng)審核,不同意操作";}
總結(jié)
以上是生活随笔為你收集整理的EasyUI DataGrid 中字段 formatter 格式化不起作用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。