easyui datagrid 绑定json对象属性的属性

EasyUI datagrid 数据绑定技巧

今天用easyui 的datagrid绑定数据时,后台提供的数据是实体类类型的,其中有一个实体类A的属性b是另一个实体类B类型的,而前台需要显示b的属性c,这下就悲剧了,前台没法直接绑定了,后来脑筋一转,想到了datagrid的列属性formatter,formatter提供了row,这样的话我们在formatter里面指定一下不就可以了吗

于是~

function dgDevice_datagrid() {
            $('#dgDevice').datagrid({
                url: 'DeviceList.ashx?action=GetDevices',
                toolbar: '#tb1',
                width: 540,
                singleSelect: true,
                remoteSort: true,
                sortName: 'SaleDate',
                sortOrder: 'desc',
                rownumbers: true,
                columns: [[
                    { title: '设备ID', field: 'DeviceID', width: 190, align: 'center' },
                    { title: '出厂日期', field: 'ExFactoryDate', width: 110, align: 'center',
                        formatter: function (val) {
                            return formatDate(val, "yyyy-MM-dd");
                        }
                    },
                    { title: '售卖日期', field: 'SaleDate', width: 110, align: 'center',
                        formatter: function (val) {
                            return formatDate(val, "yyyy-MM-dd");
                        }
                    },
                    { title: '账户', field: 'AccountName', width: 80, align: 'center',
                        formatter: function (value, row, index) {
                            return row.Account.AccountName;
                        }
                    }
                ]],
                onSelect: function (rowIndex, rowData) {
                    dgSensor_datagrid(rowData.DeviceID);
                }
            });
        }

完美~

转载于:https://www.cnblogs.com/luludongxu/p/4080837.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值