Jan 21, 2013, 3:10 PM
Grid Panel Remote Loading
Hi,
I am making my first app in EXT.net in MVC 4.
My problem is I make a call to my action to get data to load into my Grid Panel like so passing in a model as a parameter. This all works fine:
So we know that data is coming back.
My Grid Panel looks like so:
Has anyone any idea why this is not working?
Thanks in advance for any help.
I am making my first app in EXT.net in MVC 4.
My problem is I make a call to my action to get data to load into my Grid Panel like so passing in a model as a parameter. This all works fine:
Ext.Ajax.request({
url: '../Tools/Test',
jsonData: Ext.JSON.encode({ model: previewModel }),
success: function (response) {
Ext.Msg.alert("Info", "Returned Data: " + response.responseText);
App.PreviewGP.getStore().loadData(response);
},
failure: function (response) {
Ext.Msg.alert("Error", response.responseText);
}
});
In My action, I create a new Array and pass this back to the Ajax call[HttpPost]
public ActionResult Test(Example model)
{
var result = model.OfficeModels.Select(office => new PreviewModel
{
GroupId = office.GroupId,
NodeId = office.NodeId
}).ToArray();
return Json(new {data = result}, JsonRequestBehavior.AllowGet);
}
The pop up in the Success response has this data:
Returned Data: {"data":[{"GroupId":40000003,"NodeId":32}]}
My Grid Panel looks like so:
pitem.Add(Html.X().GridPanel()
.ID("PreviewGP")
.Title("Preview")
.Header(true)
.Border(false)
.Margins("5 5 5 5")
.Frame(true)
.Flex(1)
.Store(neighborStore => neighborStore.Add(Html.X().Store()
.AutoLoad(false)
.ID("PreviewStore")
.Reader(reader => reader.Add(Html.X().JsonReader().Root("data")))
.Model(model => model.Add(Html.X().Model()
.Fields(fields =>
{
fields.Add(Html.X().ModelField().Name("GroupId"));
fields.Add(Html.X().ModelField().Name("NodeId"));
}))
)
))
.ColumnModel(columnModel =>
{
columnModel.Columns.Add(Html.X().Column().Text(_ServerInformation.GroupID_Text).DataIndex("GroupId"));
columnModel.Columns.Add(Html.X().Column().Text(_ServerInformation.NodeID_Text).DataIndex("NodeId").Flex(1));
})
.View(view => view.Add(Html.X().GridView()))
);
However all that happens is a few blank rows appear in the Grid but no data.Has anyone any idea why this is not working?
Thanks in advance for any help.