Results 1 to 3 of 3

Thread: [4.1.1] Grid List Filter: Dynamically construct the list based on the data

  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    48

    Default Answered: [4.1.1] Grid List Filter: Dynamically construct the list based on the data

    Hi,

    I have a grid, and local filters to it.
    I would like to change one of my basic string filter to a list, and populate the list from the unique list of strings in that column rather than a fixed list that I define in the code.

    For example for now I use:
    Code:
    	filter: {
    		type: 'list',
    	        options: [
    	            "my-first-option",
    	            "my-second-option",
    	            "my-third-option",
    	        ]
    	}
    But the list might change, and I do not want to create another service on the server-side that returns only the different options, or add some callbacks or listeners and then populate the list with some javascript code.

    Rather, I would like to be able to do something similar to:

    Code:
    		filter: { type: 'list' }
    aAd that the list of choices is created from the data
    All my filters are local, so there is no need getting the list from somewhere else.

  2. I think this may be what you're looking for:
    http://docs.sencha.com/ext-js/4-1/#!...method-collect

    That method will give you a unique list of values from a given field (or generally from a column in a grid provided it uses a dataIndex that's the same as the field in the store you're collecting from).

  3. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    I think this may be what you're looking for:
    http://docs.sencha.com/ext-js/4-1/#!...method-collect

    That method will give you a unique list of values from a given field (or generally from a column in a grid provided it uses a dataIndex that's the same as the field in the store you're collecting from).

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    48

    Default

    Thanks slemmon,
    It seems to do the job indeed, thanks!
    But I still need to post-process the received data with a listener on the 'load' to populate the options in the column.

    A good improvement to ExtJS would be to automatically do it if we define a filter type 'list' with no options (automatically take the collect() from the data).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •