今天用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);
                }
            });
        }

完美~

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2022-01-08
  • 2021-08-07
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-12-20
相关资源
相似解决方案