PDA

View Full Version : 2.0 ComboBox.expand() with SimpleStore



alleno
23 Nov 2007, 1:19 PM
I have a combobox that uses a simplestore for it's data. The cb is disabled unless the user clicks a checkbox. I'd like for the cb to expand when the checkbox is clicked. I've spent many hours trying to figure it out and only manage to come up with more questions.
What is the event that is firing when a user clicks the drop down arrow to expand the combobox?It would be nice to be able to expand the drop down even when the user clicks elsewhere on the combobox as well. Handling focus seems to work for capturing the event but I cannot get expand to work from my focus event handler or from the checked handler of the checkbox.
What has to be set that I haven't set in order for the combobox to respond to the select method?I tried using the select method as well hoping that would cause the combobox to expand but I get an error there instead:

error quoted from firebug:


this.view has no properties
select(0, true)ext-all-debug.js (line 26820)
visitCheck()scp.php# (line 240)
fire()ext-all-debug.js (line 1504)
fireEvent()ext-all-debug.js (line 1201)
setValue(true)ext-all-debug.js (line 27066)
onClick()ext-all-debug.js (line 27055)
h(Object browserEvent=Event blur button=-1 type=blur)ext-all-debug.js (line 1629)
getViewWidth(click clientX=0, clientY=0)ext-base.js (line 10)

chrome://firebug/content/blank.gif this.view.select(index);
Maybe this error has something to do with the fact that I'm using a simplestore with no reader?I tried adding a call to loadData for that store in the checked event handler but I end up with the same error even though it seems I'm managing to load the store on the check event.

code snippets:


<body>
...
<td id="lblcbvisit"></td>
<td id="lblpapsmearfrequency"></td>
...
</body>

<script>

// create namespace
Ext.namespace('ns_scp');

Ext.onReady(function()
{
ns_scp.app.init();
}
);


// create application
ns_scp.app = function()
{
// do NOT access DOM from here; elements don't exist yet

//private variables

...
var chkvisitsched;
var papstore;
var cbPap;
...
var pap = [ [0,'Annually'], [1,'At each visit'] ];


// private functions

function visitCheck(chk,e)
{
cbPap.setDisabled(!chk.checked);
if (chk.checked)
{
// cbPap.expand();
LoadPapStore();
cbPap.select(0,true);
}
}

...

// public space
return {
// public properties, e.g. strings to translate

// public methods
init: function ()
{

...

cbPap = new Ext.form.ComboBox({
store: papstore,
title : 'Pap Smear Frequency...',
emptyText: 'Performed how often...',
displayField: 'value',
valueField: 'id',
forceSelection : true,
mode: 'local',
disabled: true
});
cbPap.render('lblpapsmearfrequency');

chkvisitsched = new Ext.form.Checkbox({
name : 'visitsched',
inputValue: 1,
boxLabel: 'Visit Schedule?'
});
chkvisitsched.on('check', visitCheck);
chkvisitsched.render('lblcbvisit');

...

}, //end of init

...

getPapStore: function()
{
return papstore;
},

getPap: function() {return pap;}




}; //end of return
}(); // end of ns_scp.app

function LoadPapStore()
{
alert(ns_scp.app.getPap());
ns_scp.app.getPapStore().loadData(ns_scp.app.getPap());
}

</script>

Let me know if I need to be more specific about something.

Any help, clarification appreciated.


Regards,
Allen O