easyUI中data-options=“field: 取出内嵌对象中的属性

问题描述:

pojo的定义如下图,在ExamSubject对象中内嵌TeacherInformation对象。
image.png
image.png
通过联表查询,获取从数据库中获取数据

    <select id="findExamSubjectForAdmin" resultMap="exam">
        select e.id, e.subjectName, e.createTime,t.teacherName,t.teacherId, t.username,  t.className, t.tel
        from exam_subject as e, teacher_information as t
        where e.teacherName=t.teacherName
    </select>

    <resultMap id="exam" type="ExamSubject">
        <id property="id" column="id"/>
        <result property="subjectName" column="subjectName"/>
        <result property="createTime" column="createTime"/>
        <result property="teacherName" column="teacherName"/>
        <association property="teacher" javaType="TeacherInformation">
            <id property="teacherId" column="teacherId"/>
            <result property="username" column="username"/>
            <result property="className" column="className"/>
            <result property="tel" column="tel"/>
            <result property="teacherName" column="teacherName"/>
        </association>
    </resultMap>

获取的数据格式如下图所示:
image.png
在ExamSubject对象中的基本类型属性(字段)可以直接通过easyUI中的field关键字取出
image.png

如果要取出TeacherInformation对象,teacher实例中的className属性,通过以下方法。

解决方法

通过data-options的formatter方法解决。

        <th width="200" align="center" data-options="field:'teacher',
                formatter:function(value){
                        if(value.className){
                        return value.className;
                                 }} ">班级名</th>
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值