9 Feb 2012 8:45 AM #1
Item Selector setValue Problem/Question (4.1B-2)
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 #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
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']);Mitchell Simoens @LikelyMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services firstname.lastname@example.org
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
9 Feb 2012 9:34 AM #3
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 #4
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"?