【问题标题】:how to set grid's column dataindex like depart.name如何设置网格的列数据索引,如depart.name
【发布时间】:2020-10-24 13:39:52
【问题描述】:

我有两节课

public class Employee
{
    int id;
    String name;
    Depart depart;
}

public class Depart
{
    int id;
    String name;
}

所以我将员工数据查询回 extjs 之类的

{total:2,list:[{"id":1,,"name":"jack",depart:{"id":1,"name":"departA"},{"id":2,,"name":"rose",depart:{"id":2,"name":"departB"}}

我设置模型喜欢

{
    ....

    {
        type: 'string',
        name: 'depart.name'
    }    

    ....
}

在网格的列中,我是这样设置的

{
    ...
    dataIndex: 'depart.name',
    ...
}

但是网格的栏目不能显示出发的名字,怎么办? 谢谢!

【问题讨论】:

    标签: extjs extjs7


    【解决方案1】:

    您可以使用mapping 来完成。

    fields: [
        { name: 'depart_name', type: 'string', mapping: 'depart.name'}
    ]
    

    在网格的列中:

    {
        ...
        dataIndex: 'depart_name',
        ...
    }
    

    【讨论】:

      【解决方案2】:

      使用渲染器功能。

      dataIndex : "anything",
      renderer  : function (val,record) {
           return record.data.depart.name;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-03-07
        • 2019-03-29
        • 2019-11-12
        • 2011-11-01
        • 2012-03-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多