Dec 01, 2012, 12:02 PM
[CLOSED] [Razor] 2.1 in MVC4 Grid using JSON reader with root property
Hi,
I cannot get a working grid when the data is loaded from a JSON webservice using the root property. To get a simplified example I converted the example: https://examples2.ext.net/#/GridPane...ON_WebService/ to MVC 4 razor as:
View:
What am I missing?
Sander
I cannot get a working grid when the data is loaded from a JSON webservice using the root property. To get a simplified example I converted the example: https://examples2.ext.net/#/GridPane...ON_WebService/ to MVC 4 razor as:
View:
@Html.X().ResourceManager()
@(Html.X().GridPanel()
.Title("TEST")
.Height(300)
.Store(store => store.Add(Html.X().Store()
.PageSize(5)
.Model(model => model.Add(Html.X().Model()
.Fields(fields => {
fields.Add(Html.X().ModelField().Name("Common"));
fields.Add(Html.X().ModelField().Name("Botanical"));
fields.Add(Html.X().ModelField().Name("Light"));
fields.Add(Html.X().ModelField().Name("Price"));
fields.Add(Html.X().ModelField().Name("Availability"));
fields.Add(Html.X().ModelField().Name("Indoor"));
})
))
.AutoLoadParams(AP =>
{
AP.Add(Html.X().Parameter()
.Name("start")
.Value("0")
.Mode(ParameterMode.Raw)
);
AP.Add(Html.X().Parameter()
.Name("limit")
.Value("5")
.Mode(ParameterMode.Raw)
);
})
.Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
.Url("/API/test")
.Json(true)
.Reader(reader =>
Html.X().JsonReader()
.Root("d.data")
.TotalProperty("d.total")
)
))
))
.ColumnModel(columnModel =>
{
columnModel.Columns.Add(Html.X().Column()
.Text("Light")
.DataIndex("Light")
.Width(180));
columnModel.Columns.Add(Html.X().Column()
.Text("Botanical")
.DataIndex("Botanical")
.Width(180));
columnModel.Columns.Add(Html.X().Column()
.Text("Common Name")
.DataIndex("Common")
.Width(180));
columnModel.Columns.Add(Html.X().Column()
.Text("Price")
.DataIndex("Price")
.Width(180));
columnModel.Columns.Add(Html.X().Column()
.Text("Indoor")
.DataIndex("Indoor")
.Width(180));
columnModel.Columns.Add(Html.X().Column()
.Text("Available")
.DataIndex("Availability")
.Width(180));
})
.BottomBar(BB => {
BB.Add(Html.X().PagingToolbar()
.DisplayInfo(true)
.DisplayMsg("Displaying plants {0} - {1} of {2}")
.EmptyMsg("No plants to display")
);
})
)
The grid is shown without data. I see that their is a http request to the json webservice with a valid JSON response. I don't get any errors but the data is not displayed in the grid.What am I missing?
Sander
Last edited by Daniil; Dec 03, 2012 at 2:21 PM.
Reason: [CLOSED]