-
8 Sep 2007 1:09 PM #1
[SOLVED] Combobox and array as source
[SOLVED] Combobox and array as source
hello.
How to load data into combobox directly from array?? What I mean is:
The value should be the selected number, that's I don't need a table with 'id' and 'value'.Code:var numbers = new Ext.form.ComboBox({ fieldLabel: 'Choose number', hiddenName:'number', store: ['6', '7', '8', '9'], displayField:'year', typeAhead: true, mode: 'local', triggerAction: 'all', emptyText:'Select value...', selectOnFocus:true, width:175 });
Greetings
MikeLast edited by mchrustek; 12 Nov 2007 at 11:39 PM. Reason: solved
-
8 Sep 2007 1:50 PM #2
This has been added into 2.0 via the SimpleStore's expandData config value which expands a one-dimensional array into a record set that can be used by the store. In 1.1 there's nothing that directly supports this.
-
10 Sep 2007 4:13 AM #3
Ok. .... this is how I solved my problem:
If any suggestions how to make it simplier or more "correct" - I'll wait for opinions.Code:store: new Ext.data.SimpleStore({ fields: ['number_id', 'number'], data : [['6','6'],['7','7'],['8','8']] }),
And other thing - I wanted to modify this, to have data for combobox into some variable, but it doesn't work. Any idea how to do it??
GreetingsCode:(...) var nbs = "[['6','6'],['7','7'],['8','8']]" store: new Ext.data.SimpleStore({ fields: ['number_id', 'number'], data : nbs }),
Mike
P.S.
This forum is very helpful for me. I'm glad that into the discussions Core Developers are involved. I've already had resolved many of problems I found while 'studying' ExtJs. Thank you.
-
10 Sep 2007 4:19 AM #4
You could write a 'make2d' method:
Untested:
Code:function make2d(arr) { //possible sanity checks on arr here. var out = []; for (var i = 0; i < arr.length; i++) out[i] = [arr[i], arr[i]]; return out; }
-
10 Sep 2007 11:17 PM #5
Thanks for cooperations and suggestion. It works.
Mike
-
8 Mar 2008 5:06 AM #6
expandData not documented
expandData not documented
I don't see expandData in the docs.
Are these forums the only way issues are tracked? I see http://extjs.com/forum/showthread.ph...345#post119345, but am not sure if that is really supposed to be a bug report.
Also, on the same topic, are patches appropriate here?
Thanks for any tips on how to find if an issue has already been reported (and issue status).
Tim


Reply With Quote
