PDA

View Full Version : Select first row in grid on view ready works with Extjs 4.1.1 but not with 4.2



tundarum
5 Nov 2013, 8:50 AM
Not sure if I'm missing something new with Extjs 4.2 or not. Using the Car Listings example, I've added the following listener to the grid panel (top grid in example) so the middle and bottom panels populate when the top grid view is ready:

viewready: {
fn: me.onMygridViewReady,
scope: me
}

The following is the onMygridViewReady function which includes the itemId of my grid:

onMygridViewReady: function(tablepanel, options) {
this.child('#mygrid').getSelectionModel().select(0);
}

This functions as expected with 4.1 but not with 4.2. Any suggestions on how to achieve the same behavior with 4.2 (select first row of grid on view ready)?

Gary Schlosberg
7 Nov 2013, 9:00 AM
What happens when it doesn't work? Are there rows in the grid when that event fires? Is this ExtJS 4.2.1?

tundarum
8 Nov 2013, 11:07 AM
Using cachefly ExtJS 4.2.0. The rows in the grid are populated with data from json file. Debugging doesn't offer any help (no errors, flags, or suggestions) using PHPStorm. I was able to get the behavior wanted by using this code for my 'viewready' listener:

onMygridViewReady: function(mygrid) {
mygrid.store.load(function(records, operation, success) {
mygrid.getView().select(0);
})
}

Above code produces desired behavior of having the first row selected and therefore triggering my onGridpanelSelect listener which populates the detail and chart panel with data from same json file.

Now that I have this behavior functioning with 4.2.0, I'd like to implement this same behavior with Sencha Architect 3 RC but I'm having no success...probably because I'm a Sencha beginner and need to learn more about how to properly implement an override in Sencha Architect. Basically, I need to create an event listener in SA3 that has only my grid itemid as a parameter.

tundarum
8 Nov 2013, 11:12 AM
Got it working in SA.