View Full Version : Item Selector setValue Problem/Question (4.1B-2)

9 Feb 2012, 8:45 AM
In using setValue for the ItemSelector, I find that I need to use something like "[0,1001,1002,1003,0]" instead of "[1001,1002,1003]" (in which case the first and last do not show up).

When I use firebug console -- e.g.,
-- works fine - all 6 values show up.

But in code - (an MVC app) when I do a store load, then use Ext.Pluck to get the values; then JSON.encode; then same Ext.getCmp('affschools-selector').setValue([1038,1024,1037,1027,1036,1025]);
-- first and last entries do not show up.

I do not know if this is a bug.
My workaround of prepending and appending '0' seems to indicate some parsing "fluke".

Please advise a better way to do this (another/better workaround ?), or confirm that it might be a bug.

Also please let me know if you need additional info.


9 Feb 2012, 9:25 AM
Using the MultiSelect demo, there is an options button that allows you to choose a set value option and it uses setValue on the ItemSelector that looks like:

Ext.getCmp(fieldId).setValue(['2', '3']);

This works flawlessly.

9 Feb 2012, 9:34 AM
Yes - I noticed that in the MultiSelect demo the setValue works flawlessly as you said....
Also, in the firebug console, doing the same, works flawlessly.

But when loading those values from a store, in code, it does not work flawlessly....
That is why I posted my question.


9 Feb 2012, 9:55 AM
Probably the issue comes from my data (coming from the backend/server/database) being integers.
So the store does not give me the single quotes surrounding each item in the array (as in the example you mentioned) - the "parsing" maybe expects a "token" of single quote or comma or close square bracket - so it ignores the first and last entry.

I am using "Pluck" to get the data out of the store --
var jsonData = Ext.encode( Ext.pluck(
Ext.pluck(affSchoolsStore.data.items, 'data'), 'departId') );

but the data come out with no single quotes....

Any suggestions on how to get the "better to have" single quotes using "Pluck"?