標籤:style blog 使用 io 資料 for 2014 art
今天用 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>
改成,前面沒有出現過的欄位,否則,不會進來格式化的。
<th data-options="field:‘使用者報表編號‘,width:80,align:‘center‘" formatter="managerstr">操作</th>
後來檢查發現 : 假設某列的 field值,在前面已經出現過,則後出現的同field列,在這裡,我的是 “審核狀態”,將按第一次出現的field列使用。假設第一次出現的field同值的列沒有formatter,興許的formatter將無效。
function managerstr(value,rowData,rowIndex) { if (rowData["審核狀態"] == "未審核") return "1"; else if (rowData["審核狀態"] == "已取回重填") return "2"; else return "已經審核,不同意操作"; }