[CLOSED] MVC ServerMapping in GridPanel

  1. #1

    [CLOSED] MVC ServerMapping in GridPanel

    Hello,

    I use MVC5 Ext.NET 3.2.1
    ServerMapping + BottomBar. Doesn't work refresh data

    After refresh:
    GUID - work
    id, name - not work.

    I done something wrong or It's bug?

    Models/Employee.cs
     public class Employee
            {
                public int ID { get; set; }
                public string GUID { get; set; }
                public string Name { get; set; }
    
                public static List<Employee> GetEmployees()
                {
    
                    List<Employee> employees = new List<Employee>()
                    {
                        new Employee
                        {
                            ID=1,
                            GUID = Guid.NewGuid().ToString(),
                            Name = "Employee 1"
                        },
                        new Employee
                        {
                            ID=2,
                            GUID = Guid.NewGuid().ToString(),
                            Name = "Employee 2"
                        },
                        new Employee
                        {
                            ID=3,
                            GUID = Guid.NewGuid().ToString(),
                            Name = "Employee 3"
                        }
                    };
    
                    return employees;
    
                }
            }
    Controllesrs/EmployeeController.cs
        public class ContractController : Controller
        {
            // GET: Contract
            public ActionResult Index()
            {
                return View(Employee.GetEmployees());
            }
    
            public ActionResult GetData()
            {
                return this.Store(Employee.GetEmployees());
    
            }
        }
    Views/Employee/Index.cshtml
     @(Html.X().GridPanel().Title("Array Grid")
            .Width(700)
            .Store(
                Html.X().Store()
                    .PageSize(10)
                    .DataSource(Model)
                    .Model(
                        Html.X().Model()
                        .Fields(
                            new ModelField("id")
                            {
                                ServerMapping = "ID"
                            },
                            new ModelField("GUID"),
                            new ModelField("name")
                            {
                                ServerMapping = "Name"
                            }
                        )
                    )
                    .ServerProxy(
                        Html.X().AjaxProxy()
                            .Url(Url.Action("GetData"))
                    )
            )
            .ColumnModel(
                Html.X().RowNumbererColumn(),
                Html.X().Column().Text("id").DataIndex("id").Flex(1),
                Html.X().Column().Text("GUID").DataIndex("GUID").Width(200),
                Html.X().Column().Text("name").DataIndex("name").Width(200)
            )
           .BottomBar(Html.X().PagingToolbar())
        )
    Last edited by fabricio.murta; Jan 06, 2016 at 4:28 PM. Reason: [CLOSED]
  2. #2
    Hello @SuperBolt!

    Server mapping does not work with Ajax Proxy. You should use ID and Name as field names in the model. Or, if you really want to use those fields, you have to do the variable mapping on the getData action so its result is the "mapped" ones.

    Here's where this question has already been asked: ServerMapping with AjaxProxy in GridPanel.

    Notice the example for Server Mapping that we have in examples explorer does not use ajax proxy.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    I Change "ServerMapping" -> "Mapping". It's working.

    Closed question, thx

Similar Threads

  1. Replies: 0
    Last Post: Feb 15, 2013, 12:48 PM
  2. [CLOSED] ServerMapping with AjaxProxy in GridPanel
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 24, 2012, 1:28 PM
  3. NullReferenceException when using ServerMapping
    By nextSTEP in forum Feature Requests
    Replies: 5
    Last Post: May 20, 2011, 1:20 PM
  4. ServerMapping with more attribute
    By Maia in forum 1.x Help
    Replies: 3
    Last Post: Aug 12, 2010, 4:48 PM
  5. [ADDED] [V0.8.2] ServerMapping
    By Timothy in forum Feature Requests
    Replies: 2
    Last Post: Sep 15, 2009, 12:09 PM

Tags for this Thread

Posting Permissions