easyui datagrid columns field 如何支持一个或多个子属性

时间:2021-03-24 07:36:06

//如果只需要一个子属性从value出发
{field:'customer',title:'会员手机',width:100,
formatter: function(value,row,index){
if (value.phone){
return value.phone;
} else {
return '';
}
}
}, //如果需要多个子属性同时显示(customer为一个类)从row出发
//自定义该类下属性name为customerName
{field:'customerName',title:'昵称',width:100,
            formatter: function(value,row,index){
                if (row.customer){
                    if(row.customer.name != '')
                        return row.customer.name;
                    else{
                        return '';
                    }
                } else {
                    return '';
                }
           }
        },
//自定义该类下属性sex为customerSex
 {field:'inventorySex',title:'性别',width:100,
            formatter: function(value,row,index){
         if (row.customer){
                    if(row.customer.sex!= '')
                        return row.customer.sex;
                    else{
                        return '';
                    }
                } else {
                    return '';
                }
           }
        },