View Full Version : Returning state to multiselect xtype?

12 Jan 2010, 6:30 AM
I have looked at the following page: http://www.extjs.com/deploy/dev/examples/multiselect/multiselect-demo.html

Copied the source files accordingly and have my multiselect control populated with some static data, just as the example. Now I need to bind that control to a specific DB table, this I assume can be done via the 'store' like all other controls I have used so far.

Don't have any questions there yet, but where I do have question, is in returning the state of a previous save operation.

Basically the list will be populated via JSON data stored in a table (or whavere) but depending on the master record selected, different items should be checked off in the initial display. Is there a way to indicate this declaratively like much of ExtJS controls, or is this (for the interim?) done programmatically using the API?

I think this might be best, as I need to re-populate the multselect box depending on a previous drop down (basically manufacturer's are selected then list of models are shown, but previously selected models which are associated with an account, should be redisplayed).

Any tips, advice, experience, etc???


12 Jan 2010, 8:14 AM
I have looked through the source code the multiselect control and it appears as though you use the API to return the selection to a previous state, cool. I have even managed to get the selection to work when using a submit button in my dialog, but now the more important question.

Which event do I capture in order to properly populate the form controls and restore previous state?

I have tried doing something like:

var win = new Ext.Window({
// Blah

win.on('load', function(){
alert('Attempt to restore multiselect selection state -- not working?');

At which point (event) would I set the values or at least the selection (I already have values initialized at the point of control initialization ) of multiselect comboboxes, etc?

EDIT | I have tried capturing several events, such as:
- activate
- beforeShow
- afterShow

None of which work unless I precede the call with an alert like this:

win.on('activate', function(){ // activate, beforeShow


alert("Window activated - ");


What event is the proper one to listen to? Do I have to use a setTimout() that seems awfully hackish, no?