1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default Unanswered: Grid Not Displaying Latest Data?

    Unanswered: Grid Not Displaying Latest Data?


    Hi All,

    I have some problems with having 2 grids, with one dependent on the first grid. Is it possible to remove all rows in a grid without removing rows in the actual store attached to it? I just want to remove all the rows on the grid display.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Answers
    3549
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Using the Array Grid example, I added this dockedItem:

    Code:
            dockedItems : [
                {
                    xtype : 'toolbar',
                    dock  : 'top',
                    items : [
                        {
                            text    : 'Switch Store',
                            handler : function() {
                                if (grid.mainStore) {
                                    grid.reconfigure(grid.mainStore);
                                    delete grid.mainStore;
                                } else {
                                    grid.mainStore = grid.getStore();
                                    grid.reconfigure(Ext.data.StoreManager.lookup('ext-empty-store'));
                                }
                            }
                        }
                    ]
                }
            ]
    So what it's doing in the button handler is if you want to clear out the grid, it uses reconfigure to pass in an empty store while first saving the populated store onto the grid so we don't loose it. If there is already something on grid.mainStore, then it is assumed that you want to go back to the populated store.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default


    Hi Mitchell,

    Thanks for the response. I tried your code to clear the grid (which it works), but when i wanted to reload in the data, then no data gets reloaded. Even the column headers get removed as well. Any ideas?

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default


    On a row select on grid 1, the listener will be fired to call populateFormGrid(poid). Inside the populateFormGrid(), i will reset some parameters and load the store. Initially, store2 is empty until a selection is made.

    Changes can be made via roweditor plugin in grid2 after loading data from store2 and postback to backend to save into database. The problem i had initially was that the updates i made on grid 2 will still be showing the old values on initial load. I checked the HTTP GET when loading the store2 after i select a row, the values obtained from DB is updated but the grid 2 is not showing the updated data. I must hit a refresh (F5) on my end before the latest data get displayed on grid 2.

    So i thought maybe if i remove all rows in the grid and force a reload, it would work. But so far no luck ...

    Code:
    Grid 1: Listener
    
    listeners: {
                'selectionchange': function(view, records) {
                    grid.down('#btnRemovePO').setDisabled(!records.length);
                    
                    var sm = grid.getSelectionModel();
                    var sel = sm.getSelection()[0];
                    
                    if(records[0]!=null){
                    
                        populateFormGrid(poid);
                        
                    }    
                }
    
            }
    
    function populateFormGrid(poid){
    
            var pageCount=store2.getCount();
            var sortDir=store2.groupDir;
            var proxy=store2.getProxy();
            proxy.extraParams.limit = pageCount;
            proxy.extraParams.dir = sortDir;
            proxy.extraParams.task = "ListProduct";
            proxy.extraParams.request = "PO";
            proxy.extraParams.start = 0;
            proxy.extraParams.returndata = poid;
            
            store2.load()
            grid2.getView().refresh();    
    }

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Answers
    3549
    Vote Rating
    850
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by shaoen01 View Post
    Hi Mitchell,

    Thanks for the response. I tried your code to clear the grid (which it works), but when i wanted to reload in the data, then no data gets reloaded. Even the column headers get removed as well. Any ideas?
    Was the live store the active store when you would load or the empty store?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Was the live store the active store when you would load or the empty store?
    Initially, the emptystore will be tagged to grid2 on load. After a selection is made on grid 1, i will then load the non-empty store into grid2. I found another way that works for me. I just toggle between the empty and non-empty store to have data displayed on grid2.

    Code:
    grid2.view.store=Ext.data.StoreManager.lookup('non-empty-store');

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    131
    Answers
    1
    Vote Rating
    1
    shaoen01 is on a distinguished road

      0  

    Default


    Hmm, it seems to be rather buggy. The data in grid2 refreshes sometimes when updated and at times not.

Thread Participants: 1