在cols:[]使用valueOperator中getter配置后,数据查询出来后没有将转换的值显示在表格中,显示的还是原值,请教下哪里有问题?
{
name:
'status'
,
label:
'状态'
,
valueOperator: {
getter:
function (dataValue
, cell
, dataGrid) {
if (dataValue ==
"0") {
return
"有效"
;
}
else {
return
"禁用"
;
}
}
完整代码:
//初始化数据表格 $(
'#datatable_role').
datagrid({
states: {
pager: {
page:
1
,
recPerPage:
2}
,
sortBy:
'seq'
,
order:
'asc'
}
,
dataSource: {
cols: [
{
name:
'name'
,
label:
'名称'}
,
{
name:
'seq'
,
label:
'排序'}
,
{
name:
'description'
,
label:
'描述'}
,
{
name:
'status'
,
label:
'状态'
,
valueOperator: {
getter:
function (dataValue
, cell
, dataGrid) {
if (dataValue ==
"0") {
return
"有效"
;
}
else {
return
"禁用"
;
}
}
}
}
,
{
name:
'opt'
,
label:
'操作'
,
valueOperator:{
getter:
function (dataValue
, cell
, dataGrid) {
return
"test"
;
}
}}
]
,
remote:
function (params) {
console.
debug(params)
;
return {
// 远程请求地址
url:
'/role/dataGrid'
,
// 请求类型
type:
'POST'
,
// 数据类型
dataType:
'json'
}
;
}
}
})
;
回贴