0
votes

My store getting created in render function that one call get fired, but my requirement call should fired conditionally but store instance should create always.

For this requirement I am using following code for create store in render function,

Ext.create('mypage.store.customTreeGridStore', {
    storeId: 'myStore',
    proxy: {
        type: 'rest',
        startParam: undefined,
        filterParam: undefined,
        sortParam: undefined,
        paramsAsJson: true,
        limitParam: 'pageSize',
        pageParam: 'pageNo',
        restService: 'rest',
        restOperation: 'getOperation',
        url: me.urlparams,
        autoLoad: true,

        actionMethods: {
            read: 'POST'
        }
    }
});

and I have added listener in store

beforeload: function(store, operation, eOpts) {
    return booleanFlag; 
}

When page is loading I could get beforeLoad boolean flag false and while page refreshing call is not getting fired but Store instance created successfully, but I have text box where I am searching grid records. When I am searching any text in textbox I could not getting any record in grid.

But once booleanFlag is true I can search result in grid successfully . So what is the best way to resolve this issue?

1

1 Answers

0
votes

Your store has autoLoad set to true, and to force the store to not load automatically all the time, you use the beforeload event to stop the autoLoad. Is this assessment correct?

How about, instead of

Ext.create('mypage.store.customTreeGridStore', {
    proxy:{
        autoLoad: true,
    },
    listeners:{
        beforeload: function(store, operation, eOpts) {
            return booleanFlag; 
        }
    }
})

removing autoLoad and loading the store after creation only if required?

var store = Ext.create('mypage.store.customTreeGridStore', {
    proxy:{
        autoLoad: false,
    }
});
if(booleanFlag) store.load();