Results 1 to 6 of 6

Thread: Force Store to reload though it's empty?

  1. #1
    Sencha User fletchergirl's Avatar
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    17

    Default Force Store to reload though it's empty?

    Good morning!

    Sorry if this question seems stupid to you, but I don't know how to solve this...
    I have a drag and drop grid that shows 'possible userrights' and 'assigned userrights'. Works fine so far but if a user has no 'assigned rights', the store just doesn't reload (obviously because it's empty?!) and the userrights of the last user stay in the grid.
    Is there a way to force this store to reload?
    I'm stuck!
    Here's the code:
    (on dblclick CCU-Grid, AssignedNotifsStore is reloading)

    Code:
       //  CCU-GRID           /////////////////////////////////////////////////////
       
        var ccuGrid = new Ext.grid.GridPanel({
            id : 'CCUTable',
            height: 200,
            title : 'Assign Macro-projects and Notifications',
            clicksToEdit : 2,
               flex: 1,
            store : combinationStore,
            sm: new Ext.grid.RowSelectionModel(),
            columns : [{
                        header : 'CCU_ID',
                        dataIndex : 'CCU_ID',
                        width : .08,
                        sortable : true,
                        editor : {
                            xtype : 'numberfield',
                            allowBlank : false
                        }
                    },{
                        header : 'Combine',
                        dataIndex : 'NAME',
                        width : .08,
                        sortable : true,
                        editor : {
                            xtype : 'textfield',
                            allowBlank : false
                        }
                    },{
                        header : 'Country',
                        dataIndex : 'NAME_ENGLISH',
                        width : .12,
                        sortable : true,
                        editor : {
                            xtype : 'textfield',
                            allowBlank : true
                            }
                    }],
                    tbar: new Ext.Toolbar({
                        height: 30,
                        items: [
                        {
                            xtype: 'tbfill'
                        },
                        {
                            text: 'Show choice',
                            icon : 'images/branch_add.png',
                            cls : 'x-btn-text-icon',
                            id: 'showCCU',
                            handler: ButtonClick
                        }]
                    }),
            view : new Ext.grid.GroupingView({
                autoFill : true,
                forceFit : true,
                startCollapsed : true,
                showGroupName : true,
                enableNoGroups : false,
                enableGrouping : true,
                enableGroupingMenu : true,
                hideGroupedColumn : false,
                markDirty : false,
                columnsText : 'Spalten ein/ausblenden',
                groupByText : 'Gruppieren nach dieser',
                showGroupsText : 'Gruppierung ein/ausschalten',
                sortAscText : 'Aufsteigend Sortieren',
                sortDescText : 'Absteigend Sortieren'
                }),
             listeners:{
                'dblclick':{
                     fn: function() {
                             var current_CCU_ID = Ext.getCmp('CCUTable').getSelectionModel().getSelections();
                            var CCUCount = Ext.getCmp('CCUTable').getSelectionModel().getCount();
                            var CCUArray = '';  
                            for (i=0;i<CCUCount;i++){
                                    if (i<CCUCount-1){
                                              CCUArray = CCUArray+current_CCU_ID[i].data.CCU_ID+',';
                                    }else{
                                              CCUArray = CCUArray+current_CCU_ID[i].data.CCU_ID;
                                    }
                            }
                
       
                    //Store laden
                    AssignedNotifsStore.load({params: {currentCCUArray:CCUArray}});
                    NotAssignedNotifsStore.load({params: {currentCCUArray:CCUArray}});
                   }
                }
             }
        });
    
    // ++++++++++++ Assign Notifications to user +++++++++++++++
        var fieldsNotifDrDr = ['NOT_ID','NOTIFICATION_TYPE','SEND_TYPE','NCO_ID','NAME'];
        
        // used to add records to the destination stores
        var blankoRecord2 =  Ext.data.Record.create(fieldsNotifDrDr);
        
        // column model object
        var cols2 = [
             {dateIndex: 'NOT_ID', header: 'NOT_ID', hidden: true},
             {header: "Notification" , width: 300, dataIndex: 'NOTIFICATION_TYPE'},
             {header: "Instant", width:80 ,dataIndex: 'SEND_TYPE'},
             {dateIndex: 'NCO_ID', header: 'NCO_ID', hidden: true},
             {dateIndex: 'NAME', header: 'NAME', hidden: true}
         ];
        
        // zugewiesene Rechte
        var assignedNOTGrid = new Ext.grid.EditorGridPanel({
            ddGroup          : 'secondGridDDGroup2',
            id                 : 'Notifics',
            store            : AssignedNotifsStore,
            flex             : 1,
            cm               : new Ext.grid.ColumnModel({
                defaults:{
                    sortable: true,
                    editable: true
                },
                columns: cols2}),
            view : new Ext.grid.GridView({
                sortAscText : 'Aufsteigend Sortieren',
                sortDescText : 'Absteigend Sortieren',
                columnsText: 'Spalten'
                }),
            enableDragDrop   : true,
            stripeRows       : true,
            title            : 'Assigned Notifications',
            listeners: {
                afterrender: {
                    fn: function() {
                        // This will make sure we only drop to the view scroller element
                        firstGridDropTargetEl2 = assignedNOTGrid.getView().scroller.dom;
                        firstGridDropTarget2 = new Ext.dd.DropTarget(firstGridDropTargetEl2, {
                                ddGroup    : 'firstGridDDGroup2',
                                notifyDrop : function(ddSource, e, data){
                                        var records =  ddSource.dragData.selections;
                                        Ext.each(records, ddSource.grid.store.remove, ddSource.grid.store);
                                        assignedNOTGrid.store.add(records);
                                        assignedNOTGrid.store.sort('NAME', 'ASC');
                                        return true
                                }
                        });
                    }
                },
                render: function() {
                    // After the component has been rendered, disable the default browser context menu
                    Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
            },
            contextmenu: function(e) {
                if (!this.contextMenu) {
                    this.contextMenu = new Ext.menu.Menu({
                    shadow: 'drop',
                    id: 'gridNOTMenu',
                    items: [{
                        text: 'Copy selected rows',
                        iconCls : 'insert-icon',
                        id: 'copySel',
                        icon: 'images/copy.png',
                        handler: ButtonClick
                    },
                    '-',
                    {
                        text: 'Copy all',
                        iconCls : 'insert-icon',
                        id: 'copyAll',
                        icon: 'images/copy.png',
                        handler: ButtonClick
                    },
                    '-',
                    {
                        text: 'Paste',
                        iconCls : 'paste-icon',
                        id: 'pasteAll',
                        icon: 'images/document_into.png',
                        handler: ButtonClick,
                        disabled: true
                    }
                ]
    
                    });
                    }
                    var xy = e.getXY();
                    this.contextMenu.showAt(xy);
            }
            }
        });
    
        // noch nicht zugewiesene Rechte
        var notAssignedNOTGrid = new Ext.grid.EditorGridPanel({
            ddGroup          : 'firstGridDDGroup2',
            store            : NotAssignedNotifsStore,
            flex             : 1,
            cm               : new Ext.grid.ColumnModel({
                defaults:{
                    sortable: true,
                    editable: true
                },
                columns: cols2}),
            view : new Ext.grid.GridView({
                sortAscText : 'Aufsteigend Sortieren',
                sortDescText : 'Absteigend Sortieren',
                columnsText: 'Spalten'
                }),
            enableDragDrop   : true,
            stripeRows       : true,
            plugins             : [userRoleFilter],
            title            : 'Not yet assigned Roles',
            listeners: {
                afterrender: {
                    fn: function() {
                        // This will make sure we only drop to the view scroller element
                        secondGridDropTargetEl2 = notAssignedNOTGrid.getView().scroller.dom;
                        secondGridDropTarget2 = new Ext.dd.DropTarget(secondGridDropTargetEl2, {
                                ddGroup    : 'secondGridDDGroup2',
                                notifyDrop : function(ddSource, e, data){
                                        var records =  ddSource.dragData.selections;
                                        Ext.each(records, ddSource.grid.store.remove, ddSource.grid.store);
                                        notAssignedNOTGrid.store.add(records);
                                        notAssignedNOTGrid.store.sort('NAME', 'ASC');
                                        return true
                                }
                        });
                    }
                }
            }
        });

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Stores have a reload method:

    Code:
    store.reload();
    Look at the API docs for the config options you can pass in the reload method.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User fletchergirl's Avatar
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    17

    Default

    Thanx for your answer Mitchell, but I need to load the store each time with a different ID so reload() would not work here.

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Sure it would...

    Code:
    //keeps other params
    store.reload({
        params : {
             id : 1
        }
    });
    //dumps other params except baseParams or extraParams
    store.load({
        params : {
             id : 1
        }
    });
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  5. #5
    Sencha User fletchergirl's Avatar
    Join Date
    Mar 2010
    Location
    Germany
    Posts
    17

    Default [Solved] Force Store to reload though it's empty?

    Thanx for your effort Mitchell. That wasn't the problem but a mistake in the PHP. I have to give back rows: [] when there's no dataset in the db.

  6. #6
    Sencha User
    Join Date
    Aug 2013
    Posts
    7

    Default Force reload page

    And is there any way to force reload of a specific page, even if it is loaded already? store.loadPage(index) tries to fetch a page before the index to accommodate for leading buffer zone, and then skips loading index-th page because it is already loaded.

    I.e. to call store.loadPage(3), will make a server call to load page 2, and after it comes back since total count is equal to count, it skips fetching page #3.

Similar Threads

  1. ComboBox force reload
    By pilote7 in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 3 Jun 2009, 4:36 PM
  2. Force Empty Field to POST
    By noso in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 8 Dec 2008, 12:39 PM
  3. How to force the reload of disabledDates
    By lobo-tuerto in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 11 Jun 2008, 8:56 AM
  4. combobox force reload
    By italoc in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 11 Apr 2008, 12:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •