Question

Why does CheckboxModel deselect all selected rows on page change when using paging toolbar? How do I stop the deselection of rows on page change?

I see there is a pruneRemoved which can be used to prevent the pruning of nodes, I set it to false, but the deselect is still fired. Not sure what else to try.

I'm assuming checkboxmodel registers with the store or maybe pagingtoolbar to be notified when the store changes...then deselects everything? Why? I need to prevent that.

Edit: The reason I don't want the deselectAll to be fired is; I attach a handler on select and deselect. Select adds rows to another grid, deselect removes them. So when the user checks a checkbox that row is added to another grid, when they uncheck it it is removed from that grid. By the grid firing a deselectAll, when the store changes, I lose all my saved rows in the other grid.

Was it helpful?

Solution

I'm not sure if this is the correct way to do this but it's working for me.

What I did was create my own Ext.grid.View. I extended ext.view.Table and over-road the onMaskBeforeShow method. This is the method that was calling deselect all on the grids selection model. As you can see I commented it out here

Ext.define('Ext.grid.SteveView', {
    extend: 'Ext.view.Table',
    alias: 'widget.stevegridview',

    onMaskBeforeShow: function(){
        var me = this,
            loadingHeight = me.loadingHeight;

        //me.getSelectionModel().deselectAll();
        me.all.clear();
        if (loadingHeight && loadingHeight > me.getHeight()) {
            me.hasLoadingHeight = true;
            me.oldMinHeight = me.minHeight;
            me.minHeight = loadingHeight;
            me.updateLayout();
        }
    }
});

Include the above script, then when you create a grid, change the viewType to stevegridview, or whatever you decide to name it

    {
        xtype: 'grid', 
        viewType:'stevegridview',
        store:'some store'
        ...
    }

The new view type will be used a the new onMaskBeforeShow() will be called.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top