PDA

View Full Version : Combobox setValue doesn't work after updating Ext from ext-1.0-beta2 to ext-1.0.1



maya
6 Jun 2007, 4:16 AM
Hi,

After updating Ext from ext-1.0-beta2 to ext-1.0.1 the Combobox setValue function doesn't work anymore (I get a JS error) (see my code below).

Any suggestions?

Thanks,
Maya

My code is:


var data_pr_order = [
['1', 'Sort by sequence'],['2', 'Sort by priority'] ];
var store_pr_order = new Ext.data.SimpleStore({
fields: ["id_pr_order", "name_pr_order"],
data : data_pr_order
});
var x = 1;
var combo_pr_order = new Ext.form.ComboBox({
store: store_pr_order,
id: "pr_order",
displayField:"name_pr_order",
valueField: "id_pr_order",
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '...',
selectOnFocus:true,
width:135,
editable: false

});
combo_pr_order.addListener("select",selectHandlerpr_order);

combo_pr_order.setValue("1");

tryanDLS
6 Jun 2007, 7:49 AM
Where is the error occurring (in ext-all-debug.js)? Is the store already loaded?

maya
6 Jun 2007, 10:02 AM
Yes, the the error occurs in ext-all.js (see attached screenshot - it highlights the specific code in which the error happens).
The error's text is: "'this.el' is null or not an object".

Please note that:
1. The code works fine using Ext's 1.0-beta2 version, and not in 1.0.1 version
2. I am running my app. in IE6 "quirks mode" (maybe this has an influence?)
3. If I create the combobox without the "setValue() code-line, it is created just fine.

Thanks,
Maya

tryanDLS
6 Jun 2007, 10:32 AM
I don't see screenshot of the error - try it with the debug code to get a better error line/message. Also, it's not in your code - are you calling applyTo on an existing field? If not, where is the autoCreate config?

Note that the form stuff wasn't complete in the beta, so there may be somethings you need to account for.

maya
6 Jun 2007, 10:56 AM
Sorry, forgot to attach the screenshot - here it is.

I create the combobox, and add it to a toolbar as follows:



<div id="third_toolbar">
</div>

<script type="text/javascript" language="javascript">
Ext.onReady(function() {
var tb3 = new Ext.Toolbar('third_toolbar');
var data_pr_order = [
['1', 'Sort by sequence'],['2', 'Sort by priority'] ];
var store_pr_order = new Ext.data.SimpleStore({
fields: ["id_pr_order", "name_pr_order"],
data : data_pr_order
});
var x = 1;
var combo_pr_order = new Ext.form.ComboBox({
store: store_pr_order,
id: "pr_order",
displayField:"name_pr_order",
valueField: "id_pr_order",
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText: '...',
selectOnFocus:true,
width:135,
editable: true

});
combo_pr_order.addListener("select",selectHandlerpr_order);
combo_pr_order.setValue("1");
tb3.addField(combo_pr_order);

function selectHandlerpr_order(item, e) {

}
});


Thanks,
Maya

maya
6 Jun 2007, 11:05 AM
Hi,

Pls. find attached another screen-shot from ext-all-debug.js - maybe it can give more info.

Thanks,
Maya

tryanDLS
6 Jun 2007, 11:29 AM
That says the Field hasn't been built yet. You can't call setValue before it has been rendered.
You need to call setValue after the field has been rendered. In this case, after it's added to the toolbar, which calls Field.render().

maya
6 Jun 2007, 11:43 AM
Thanks a lot, Tim.

It works fine now (I can't explain why the original code worked in the previous version).

Thanks again,
Maya

tryanDLS
6 Jun 2007, 12:01 PM
That's why I recommended upgrading :) There were still some flaky things happening in forms in the beta releases. And although I don't have the beta source handy, I recall that there some issue about setValue's behavior/timing.

maya
7 Jun 2007, 12:16 AM
Thanks!