21 May 2012 6:13 AM #1
Suggested Feature / Functionality
Suggested Feature / Functionality
I think this is more of a request for Architect than for Sencha Touch 2 but I'm not sure. I've gone through a lot of pain getting select fields / pickers to filter a stores data repopulate the selector(s)... Here are my 2 suggestions and they kind of work together.
1) Aside from linking a Select Field to a data store, the ability to only display "unique" values for that column.
2) The ability to filter that same table after a selection is made.
What's the use case for this? Pretty much any type of configurator or faceted search could be powered by this if the data source is normalized / flat table.
There are so many ways this could be done and there is no clear "best practices" for this type of functionality. Right now I have a controller action set up for each of my selectors that is being called on Change. This get's messy because as you change one selector, you are updating the data and all the other selectors tied to this data also change so their on "Change" event fires as well. To get around this, I nested everything inside their Controller Action into an if statement that checks to see if newValue and oldValue are the same. If they are, then I don't do anything.
It has taken me days to work through this with only 3 fields filtering my data. The other issue with doing it my way is that clearFilter() clears ALL filters. So every time I have to clear a selection, I need to clear all of the filters then re-apply them after the change is made. It's really a convoluted mess and I'm sure there is a better way of doing it.
Just a high level of how I am doing it now - 1 data store with all my data in it, 3 data stores to drive my selectors. I use Array.include() to build arrays of unique data based on the 1 main data store and use those arrays to populate my 3 selectors when selections are made. Every time a selection changes, I have to clear the filters on my main store and the repopulate my selector stores. I have a controller action set up for each of the selectors that handles these functions.
I don't know if that is the best way to do it, maybe putting a function on each of the selectors would be better but I imagine there would be issues here as well because the clearFilter() method clears all filters.
If other people are doing this different ways, I would love to hear the suggestions you have.
23 May 2012 6:52 AM #2
- Join Date
- Mar 2007
- St. Louis, MO
- Vote Rating
So what you want is to have 3 select fields use 1 store but of course you can't as if you want different data in each view then you need a different store instance for each. Back when I used Ext JS 3 I had to do something similar so I made a store manager of sorts that it could create child stores and sync everything with them.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
http://www.JSONPLint.com - Source to lint your JSONP!
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.