Search code examples
extjs7

EXTJS 7.X Modern Kit Button Disabled


I want to disabled an Export Button when the data not available in the grid.


Solution

  • Your grid should have a store set up that loads data? You could listen on your store for data changes.

    listeners: {
            datachanged: function(store, eOpts) {
                //localize your button
                let yourButtonInToolbar,  //Get Button (e.g. via ComponentQuery)
                    boolean = store.getData().getCount() === 0;
    
                yourButtonInToolbar.setDisabled(boolean);
            }
        }
    

    In this event the store should already have set the data if changes occured. I did a boolean depending on the Output of the getCountmethod inside the result of the getData method on the store.

    With this boolean I use the setDisabled method on the localized button in your toolbar.

    I hope this helps.