Oct 24, 2012, 12:13 PM
[CLOSED] ServerMapping with AjaxProxy in GridPanel
Hi,
I have a problem when using ServerMapping with AjaxProxy in GridPanel
Here is my test code:
Views:
Another question is: When I use StoreFor<> Control in the Views, How can I add new Field in the Store Model with ServerMapping?
Thanks in advance.
I have a problem when using ServerMapping with AjaxProxy in GridPanel
Here is my test code:
Views:
@using System.Globalization
@using Unify.Admin.Controllers
@{
Layout = null;
}
@Html.X().ResourceManager()
@(Html.X().GridPanel().ForceFit(true)
.Store(s =>
s.Add(Html.X().Store()
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetEvents"))
.Reader(Html.X().JsonReader().Root("data")))
//.DataSource(MyEvent.GetEvents())
.Model(Html.X().Model()
.Fields(f =>
{
f.Add(Html.X().ModelField().Name("StudentName").Type(ModelFieldType.String).ServerMapping("Student.Name"));
f.Add(Html.X().ModelField().Name("StudentNo").Type(ModelFieldType.String).ServerMapping("Student.StudentNo"));
f.Add(Html.X().ModelField().Name("ID"));
f.Add(Html.X().ModelField().Name("Desc"));
}))
)
)
.ColumnModel(c =>
{
c.Columns.Add(Html.X().Column().DataIndex("ID").Text("ID"));
c.Columns.Add(Html.X().Column().DataIndex("Desc").Text("Desc"));
c.Columns.Add(Html.X().Column().DataIndex("StudentName").Text("StudentName"));
c.Columns.Add(Html.X().Column().DataIndex("StudentNo").Text("StudentNo"));
}))
Controllers:public StoreResult GetEvents()
{
List<MyEvent> events = MyEvent.GetEvents();
return new StoreResult(events, events.Count);
}
Classes public class MyEventBase
{
public int ID { get; set; }
}
public class MyEvent : MyEventBase
{
public MyStudent Student { get; set; }
public string Desc { get; set; }
public static List<MyEvent> GetEvents()
{
return new List<MyEvent>
{
new MyEvent
{ID = 1, Desc = "EventDesc1", Student = null},
new MyEvent
{ID = 2, Desc = "EventDesc2", Student = new MyStudent {StudentNo = "0001", Name = "Student Name1 "}}
};
}
}
public class MyStudent
{
public string StudentNo { get; set; }
public string Name { get; set; }
}
It works fine when I use .DataSource(MyEvent.GetEvents()) in the Views.Another question is: When I use StoreFor<> Control in the Views, How can I add new Field in the Store Model with ServerMapping?
Thanks in advance.
Last edited by Daniil; Oct 26, 2012 at 5:54 PM.
Reason: [CLOSED]