MVC GridPanelFor example with batch update
Hi,
does anybody have an example of using batch update with GridPanelFor.
I've followed this example: Grid with batch saving
But don't know how to get the store of the GridPanel.
I've tried the following without success as panel.GetStore() returns null:
Code:
public ActionResult HandleItemChanges(StoreDataHandler handler)
{
var panel = (this.GetCmp<GridPanel>("PricePanel"));
var store = panel.GetStore();
foreach (SubscriptionItem created in items.Created)
{
var record = store.GetByInternalId(created.PhantomId);
record.CreateVariable = true;
record.SetId(created.ItemId);
record.Commit();
created.PhantomId = null;
}
foreach (SubscriptionItem deleted in items.Deleted)
{
store.CommitRemoving(deleted.OldItemId.Value);
}
foreach (SubscriptionItem updated in items.Updated)
{
var record = store.GetById(updated.OldItemId);
record.Commit();
}
return this.Direct();
}
Can anyone advise how to commit the changed store records?
Thanks in advance
Ian
Problem is accessing the store of the GridPanel in code behind
Hi LikeWatchStar,
thanks for your response.
We can get the records of the GridPanel without any problem:
Code:
buttons.Add(Html.X().Button()
.ItemID("btnSync")
.Text("Sync")
.Icon(Icon.Disk)
.DirectEvents(de =>
{
de.Click.Url = Url.Action("HandleItemChanges");
de.Click.ExtraParams.Add(new Parameter()
{
Name = "__RequestVerificationToken",
Value = "App.AntiForgery.getValue()",
Mode = ParameterMode.Raw
});
de.Click.ExtraParams.Add(new Parameter
{
Name = "data",
Value = "this.up('window').down('component[itemId=PricePanel]').store.getChangedData()",
Mode = ParameterMode.Raw,
Encode = true
});
}));
The issue we are facing is how to get the store of the gridpanel in the code behind. We need the store to be able to commit the records after the database has been updated.