[CLOSED] Filters in Multiselect

  1. #1

    [CLOSED] Filters in Multiselect

    Hi,

    I want to filter Multiselect List in mvc with some additional requirement.
    My requirement is when user select an item in multiselect & search for other item, that selected item should be maintained
    For Ex:
    If user has selected country "India" and search the countries starting with 'A' then multiselect should display all the countries starting with 'A' including country "India" selected.

    Here is my code:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.Net.MVC v2 Example</title>  
    </head>
    <script>
    
      var onCountryChange = function (textField, newValue, oldValue) {
            var multiSelect = App.UniverseCountriesList,
            store = multiSelect.getStore();
    
            store.clearFilter();
            store.filter(multiSelect.displayField, newValue);
        };
    
    </script>
    
    <body>
        @Html.X().ResourceManager()
        
         @(Html.X().TextField().ID("TxtUnCountries").Listeners(ls => ls.Change.Fn = "onCountryChange").Width(250)),  
    
        MultiSelect1
      
        <br />
      
        @(Html.X().MultiSelect()
            .ID("MultiSelect1")
              
            .Store
             (
                    X.Store().ID("strUnCountries").Model(
                    X.Model().Fields(
                         new ModelField("COUNTRY_DESC"),
                         new ModelField("COUNTRY_CD"),
                         new ModelField("REGION2_CD")
                          )
                   ).DataSource(Model.CountryList))
            .ListConfig(Html.X().BoundList()
                .Listeners(events =>
                    events.ItemClick.Handler = "App.MultiSelect2.getStore().add(record.copy())"
                )
            )
        )
      
       
    </body>
    </html>

    Thanks
    Last edited by Daniil; Jul 19, 2013 at 5:34 AM. Reason: [CLOSED]
  2. #2
    Hi @PriceRightHTML5team,

    You should use a Store's filterBy method instead of the filter one.
    http://docs.sencha.com/extjs/4.2.1/#...ethod-filterBy

    You can implement custom filtering logic in a JavaScript function passed to a filterBy call.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @PriceRightHTML5team,

    You should use a Store's filterBy method instead of the filter one.
    http://docs.sencha.com/extjs/4.2.1/#...ethod-filterBy

    You can implement custom filtering logic in a JavaScript function passed to a filterBy call.
    Hi,

    Thanks Daniil,

    Can u tell how to check whether Multiselect item is selected or not in jquery?
  4. #4
    In jquery? Do you mean in JavaScript?
  5. #5
    Quote Originally Posted by Daniil View Post
    In jquery? Do you mean in JavaScript?
    Hi,
    yes i mean in javascript.
  6. #6
    You can do it this way.
    var selected = App.MultiSelect1.getSelected(),
        record = App.MultiSelect1.getStore().getAt(0);
        
    alert(selected.indexOf(record) > -1)
  7. #7
    Quote Originally Posted by Daniil View Post
    You can do it this way.
    var selected = App.MultiSelect1.getSelected(),
        record = App.MultiSelect1.getStore().getAt(0);
        
    alert(selected.indexOf(record) > -1)

    Thanks Daniil, filter is working fine.

Similar Threads

  1. Replies: 0
    Last Post: Oct 12, 2012, 10:45 AM
  2. Replies: 4
    Last Post: May 09, 2012, 9:24 PM
  3. Replies: 4
    Last Post: Feb 20, 2012, 11:14 AM
  4. Replies: 3
    Last Post: Jan 12, 2012, 3:26 PM
  5. Replies: 0
    Last Post: Mar 09, 2010, 7:28 AM

Posting Permissions