MVC GridPanelFor example with batch update

  1. #1

    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:

            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
  2. #2
    the DataSource of Store is disposed(release),when you databind(),you just can use
    <ext:Parameter Name="rows" Value="Ext.encode(#{GridPanel_File}.getRowsValues())" Mode="Raw"></ext:Parameter>
    to get rows
  3. #3

    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:

                                        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.

Similar Threads

  1. [CLOSED] Batch Update with MVC
    By Z in forum 3.x Premium Help
    Replies: 16
    Last Post: Aug 17, 2015, 6:55 PM
  2. [CLOSED] Batch Update Issue
    By shaileshsakaria in forum 2.x Premium Help
    Replies: 2
    Last Post: Apr 03, 2013, 8:08 AM
  3. [CLOSED] GridPanel Batch Update does not send data
    By chrish in forum 2.x Premium Help
    Replies: 11
    Last Post: Feb 18, 2013, 4:38 AM
  4. Batch Update
    By shaileshsakaria in forum 2.x Help
    Replies: 1
    Last Post: Jan 18, 2013, 5:17 PM
  5. [2.1] GridPanelFor Batch Update
    By millenovanta in forum 2.x Help
    Replies: 20
    Last Post: Dec 26, 2012, 1:27 PM

Tags for this Thread

Posting Permissions