I posted this on the Sencha forums, I also wanted to post it here just in case:
I have a GridPanel that uses PagingToolbar and CheckboxSelectionModel. I want to track page selections. I'm almost there, but I'm having problems with the PagingToolbar controls (like the next page) that trigger the "changechange" event in 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 suggested that I can select the entries in the load event and not trigger any events.
What happens here is that the changechange event is fired when the data page changes, and I don't want this to happen. Ideally, only the user's click will be tracked as "changechange" events, and not any other component events that bubble up and trigger an event on my selection model. Looking at the source code, the only event I could see was that the fires on the PagingToolbar were "changing." I tried to keep track of how the GridPanel, TablePanel, Gridview, etc. are handled, but I just don't see the path to the event. Even then, I'm not sure how to suppress events from the PagingToolbar in the SelectionModel.
Thanks in advance Tom