vendredi 23 mars 2018

ExtJS: Is possible to state if else condition for bind in grid panel?

Inside the ViewModel I've defined 2 stores and I'm using a gridpanel as view. Is there any chance to state if else condition for bind property inside gridpanel?

ViewModel:

stores: {
        dataStore: {
            model: 'MyApp.first.Model',
            autoLoad: true,
            session: true
        },

        listStore: {
            model: 'MyApp.second.Model',
            autoLoad: true,
            session: true,
        },

and on grid panel I want to do this condition;

Ext.define('MyApp.base.Grid', {
    extend: 'Ext.grid.Panel',

    // Currently binds directly to listStore
    bind: '{listStore}',

    // but I'm trying to implement a proper adjustment such as this;
    // bind: function () {
    //     var username = localStorage.getItem('username');
    //     if (username === 'sample@adress.com') {'{dataStore}';} else {'{listStore}'}
    // },

Aucun commentaire:

Enregistrer un commentaire