View Full Version : Grid ListFilter values from store

2 Feb 2012, 6:27 AM
Hey guys!

I'm using a grid within my application, which is connected to a store and a model. The raw data of one specific column consists only of an ID - 1, 2, 3 etc. I'm using a renderer on this gridcolumn to fetch another string value based on this ID, from a separate store. So the column might display "Donald Duck" when the raw data in the store/model is actually 2.

All this works fine (with some help from here...). Now I'm trying to add a listfilter to this column. By inserting the possible values manually in code it all works fine, like this: (code from column definition)

filter: { type: 'list',
options: [
['1', 'Mickey Mouse'],
['2', 'Donald Duck'],
['3', 'Chuck Norris']

However, I'd really like these values and labels to be loaded dynamically from my second store "Characters". I've tried many variations of the following:

filter: { type: 'list',
dataIndex: 'character_id',
labelField: 'character_name',
store: Ext.data.StoreManager.lookup('Characters')

... but it seems no matter what I try it just won't work. I've tried with and without the dataIndex/labelFields.

So, in short - I have a main grid displaying MOVIES from the "main" store Movies. One of the columns display CHARACTER, but the grid filter won't load from the "second" store Characters.

Any and all help is very much appreciated!

2 Feb 2012, 6:39 AM
Take a look at the filter() and filterBy() methods in the API docs for Ext.data.Store (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Store). You could dynamically set filters in the main Store's beforeLoad event.

2 Feb 2012, 7:45 AM
Friend! ;)

I'm admittedly not very fluent in the Ext JS-lingo yet but I'm pretty sure this is not what I'm looking for. I don't want the grid's store to be filtered initially, I just want to populate one column's ListFilter-values from another store.

3 Feb 2012, 3:50 PM
Hello again,

Is there no experience out there on how to use the ListFilter with it's store-property? I just can't figure it out!

4 Feb 2012, 8:09 AM
FilterList uses ListMenu class, in there you can only define the "ID" and "Text", if you really need to use "id","Text" and "Value", you have to change the Listmenu class. This is the only way in 4.0.7 and 4.1, hope sencha team can solver this in the future.

4 Feb 2012, 9:47 AM
I looked at the source of ListMenu and ListFilter. As I said, I'm not a very experienced developer but it seems to me this is somewhat broken...

I've tried using another store, and tried specifying a specific 'id' field in the store, but it just won't work very well. Most of the time it isn't working at all, in some variations it does SOMETHING but it never really works in a useful way.

6 Feb 2012, 10:07 AM

9 Feb 2012, 7:58 AM

Thanks a lot for your suggestion. It seems like that thread offers a solution to this problem, however I'm unable to test this right now. I'll mark your reply as Best Answer.