Render a column of Complex type "OneToOne" with GridPanel - URGENT!

  1. #1

    Render a column of Complex type "OneToOne" with GridPanel - URGENT!

    Hello, I have a very simple straight forward question. I am building a gridpanel from a collection of EmployeeJobs. Each EmployeeJob contains an Employee object I would like to bind the column Employee.EmployeeFullName to the grid however I've spent almost the full day wondering how to do that and searching but could not find one example.


    please note the issue here >> Html.X().Column().Text("Employee Number").DataIndex("Employee.EmployeeNumber").Width(175),

    Note all other columns are binding fine the Employee.EmplyeeNumber is blank.


    >>>>code has been simplified

    Using MVC and Ext.net.Mvc 3.2
    
    @model IEnumerable<ECIS.Model.EmployeeJob>
    @{
        ViewBag.Title = "Simple Array Grid With Local Paging and Remote Reloading - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    
    @(Html.X().GridPanel()
            .Title("Array Grid")
            .Width(700)
            .Store(
                Html.X().Store().ID("Store1").Model(Html.X().Model()
                        .Fields(
                            new ModelField("EmployeeNumber"),
                            new ModelField("PositionNumber"),
                            new ModelField("JobSuffix"),
                            new ModelField("EmployeeOrgCode")
                        )
                      ).DataSource(Model)
                )
         
            .ColumnModel(
                Html.X().RowNumbererColumn(),
                Html.X().Column().Text("Employee Number").DataIndex("Employee.EmployeeNumber").Width(175),
                Html.X().Column().Text("Position Number").DataIndex("PositionNumber").Width(175).Renderer(RendererFormat.None),
                Html.X().Column().Text("Job Suffix").DataIndex("JobSuffix").Width(175),
                Html.X().Column().Text("Org. Code").DataIndex("EmployeeOrgCode").Width(185)
            )
        
    )
    controler

      public partial class TestController : Controller
        {
    
            public ActionResult index()
            {
                ECIS.BLL.EmployeeJobBLL bll = new ECIS.BLL.EmployeeJobBLL();
                List<EmployeeJob> empJobs = bll.SearchEmployees("1111", "", "", "");
                return View(empJobs);
            }
    
        }
    model

     public partial class EmployeeJob 
        {
            public EmployeeJob()
            {
                this.Employee = new Employee();
            }
    
            public string JobSuffix { get; set; }
            public string JobStatus { get; set; }
            public string EmployeeOrgCode { get; set; }
    
            public Employee Employee { get; set; }
    }
    
     public class Employee
        {
    
            public string EmployeeNumber { get; set; }
    
            }
  2. #2

    Found an example!

    I found an example

    http://mvc3.ext.net/#/GridPanel_Data...Field_Mapping/

    
    
    <script>
        var EmployeeRenderer = function (value) {
            return value.EmployeeNumber;
        };
    
    
        var EmployeeNameRenderer = function (value) {
            return value.EmployeeFullName;
        };
    </script>
    
    
    
    
    
    
    
    @(Html.X().GridPanel()
            .Title("Array Grid")
            .Width(1200)
            .Store(
                Html.X().Store().ID("Store1").Model(Html.X().Model()
                        .Fields(
                            new ModelField(){Name = "Employee",Type = ModelFieldType.Object},
                            new ModelField(){Name = "Employee",Type = ModelFieldType.Object},
                            new ModelField("PositionNumber"),
                            new ModelField("JobSuffix"),
                            new ModelField("JobTitleDesc"),
                            new ModelField("EmployeeOrgCode")
                        )
                      ).DataSource(Model)
                )
    
                .ColumnModel(
                Html.X().RowNumbererColumn().Width(50),
                Html.X().Column().Text("Employee Number").DataIndex("Employee").Width(200).Renderer("EmployeeRenderer"),
                Html.X().Column().Text("Employee Name").DataIndex("Employee").Width(300).Renderer("EmployeeNameRenderer"),
                Html.X().Column().Text("Position Number").DataIndex("PositionNumber").Width(125).Renderer(RendererFormat.None),
                Html.X().Column().Text("Job Suffix").DataIndex("JobSuffix").Width(125),
                Html.X().Column().Text("Job Title Desc").DataIndex("JobTitleDesc").Width(200),
                Html.X().Column().Text("Org. Code").DataIndex("EmployeeOrgCode").Width(200)
            )
    
    )
  3. #3
    I believe you have it working now then, right? Thanks for sharing the outcome and solution for the problem!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 1
    Last Post: Sep 11, 2013, 5:39 PM
  2. Render Hidden to html Input type="hidden"
    By lasalle in forum 1.x Help
    Replies: 2
    Last Post: Jun 25, 2013, 7:24 AM
  3. Replies: 3
    Last Post: Jun 21, 2013, 12:53 AM
  4. Replies: 7
    Last Post: Jul 04, 2012, 3:58 PM
  5. Replies: 4
    Last Post: May 22, 2012, 10:40 AM

Tags for this Thread

Posting Permissions