zoukankan      html  css  js  c++  java
  • Easy UI 关联表的字段展示

    刚接触的easy UI ,发现展示关联表的字段的时候,卡住了 好一段时间,后来通过qq群询问,终于得到答案

    实体Record 

     public class Record:Base
        {
            public Guid UserId { get; set; }
            public Guid CarId { get; set; }
    
            /// <summary>
            /// 价格
            /// </summary>
            public decimal TotalPrice { get; set; }
    
            /// <summary>
            /// 公里数
            /// </summary>
            public decimal Kilometre { get; set; }
    
            /// <summary>
            /// 单价
            /// </summary>
            public decimal UnitPrice { get; set; }
    
            public virtual Car Car { get; set; }
            public virtual User User { get; set; }
        }
    View Code

    实体Car

     public class Car : Base
        {
            /// <summary>
            /// 车牌
            /// </summary>
            [StringLength(20)]
            public string Number { get; set; }
    
            /// <summary>
            /// 颜色
            /// </summary>
            [StringLength(5)]
            public string Color { get; set; }
    
            /// <summary>
            /// 名称
            /// </summary>
            [StringLength(10)]
            public string Name { get; set; }
    
            /// <summary>
            /// 用户id
            /// </summary>
            public Guid UserId { get; set; }
        }
    View Code

    在ui层 显示 car 的字段 Nuber 如下

         $('#dg').datagrid({
                    url: 'record/page',
                    pagination: true,
                    rownumbers: true,
                    singleSelect: true,
                    //checkOnSelect: false, selectOnCheck: false,
                    columns:
                 [[
                     { field: "Id", title: "Id", hidden: true },
                     //{ field: "ck", checkbox:true },
    
                     { field: "RefuelTime", title: "加油日期" },
    
                     {
                         field: 'Car', title: "车牌", formatter: function (value) {
                             return value.Number
                         }
                     },
                     {
                         field: "Phone", title: "电话", formatter: function (value, row, index) {
                             return row.User.Phone;
                         }
                     },
                     
                     { field: "TotalPrice", title: "加油总价" },
                      { field: "UnitPrice", title: "每升价格" },
                      { field: "Kilometre", title: "行驶里程" }
                 ]]
                });
            });
    View Code
  • 相关阅读:
    第一周软件测试
    第八周
    第七
    安卓第六周作业
    安卓第五周
    第四周作业
    Jsp第十次作业
    Jsp第九次作业(带验证码的email)
    Jsp第八次作业
    Jsp第七次作业email
  • 原文地址:https://www.cnblogs.com/Linyb/p/4368843.html
Copyright © 2011-2022 走看看