Results 1 to 2 of 2

Thread: Using PagingToolbar and CheckboxSelectionModel in single GridPanel

  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    4
    Vote Rating
    0
      0  

    Default Using PagingToolbar and CheckboxSelectionModel in single GridPanel

    I have a GridPanel that utilizes a PagingToolbar and a CheckboxSelectionModel. I want to keep track of selections across pages. I'm nearly there, but I'm running into issues with the PagingToolbar controls (such as next page) firing a 'selectionchange' event on the my selection model.

    Here's a simplified sample of my code:

    Code:
        var sm = Ext.create('Ext.selection.CheckboxModel', {
            listeners:{
                selectionchange: function(selectionModel, selectedRecords, options){
                    console.log("Selection Change!!");
                    // CODE HERE TO KEEP TRACK OF SELECTIONS/DESELECTIONS
                }
            }
        });
    
        var grid = Ext.create('Ext.grid.Panel', {
            autoScroll:true,
            store: store,
            defaults: {
                sortable:true
            },
            selModel: sm,
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: store,
                dock: 'bottom',
                displayInfo: true
            }],
            listeners: {'beforerender' : {fn:function(){
                store.load({params:params});
    
            }}}
        });
        store.on('load', function() {
            console.log('loading');
            console.log(params);
            console.log('selecting...');
            var records = this.getNewRecords();
            var recordsToSelect = getRecordsToSelect(records);
            sm.select(recordsToSelect, true, true);
        });
    I assumed that I could select the records on the load event and not trigger any events.

    What's happening here is that the selectionchange event is being triggered on changing the page of data and I don't want that to occur. Ideally, only user clicking would be tracked as 'selectionchange' events, not any other component's events bubbling up and triggering the event on my selection model. Looking at the source code, the only event I could see that fires on the PagingToolbar is 'change'. I was trying to follow how that is handled by the GridPanel, TablePanel, Gridview, etc, but I'm just not seeing the path of the event. Even then, I'm not sure how to suppress events from the PagingToolbar to the SelectionModel.

    Thanks in advance,
    Tom

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You may want to take a look at this community extension: http://www.sencha.com/forum/showthre...ionPersistence

    I haven't used it but it could suit your needs.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

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