1. #1
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    32
    Vote Rating
    1
    tangalla is on a distinguished road

      1  

    Default Unanswered: Combobox not removing filter

    Unanswered: Combobox not removing filter


    Hello,

    Combbox is not removing filter on store. I have multiple comboboxes with same store. The filter criteria is not removed it still shows the filtered data.

    Steps to reproduce.
    Step 1. Type AL
    step 2. click on 2nd combo triger
    the second combo box shows the filter data what we did on 1st combo

    var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
    {"abbr":"AL", "name":"Alabama"},
    {"abbr":"AK", "name":"Alaska"},
    {"abbr":"AZ", "name":"Arizona"}
    //...
    ]
    });

    Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State 1',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
    });
    Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State 2',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
    });

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,770
    Answers
    355
    Vote Rating
    165
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    If the two combos are sharing the same store they'll also share the same filtered store.
    Are you wanting to have the combos and their stores operate separately (filter one and the other doesn't get filtered, etc.)?

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    32
    Vote Rating
    1
    tangalla is on a distinguished road

      0  

    Default


    Yes. Right now i did this to solve my problem
    listeners:{focus:
    function(field, value){this.getStore().clearFilter()}
    }

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,109
    Answers
    345
    Vote Rating
    503
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    If they share the same store then they must have the same filters applied. If you want them to behave separately then they will need to use unique stores.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,770
    Answers
    355
    Vote Rating
    165
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    A great way to share a store definition, but have unique instances per component is to define the store and give it an alias like so:

    Code:
    Ext.define('MyApp.store.States', {
        extend: 'Ext.data.Store',
        alias: 'store.states',
        fields: ['abbr', 'name'],
            data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
            //...
        ]
    });
    Then when you instantiate a component like combobox you can do:
    store: { type: 'store' }

    Within that config you can pass in any needed configs for that component's store and they will override the base configs in the store's definition.

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Location
    New York City
    Posts
    109
    Answers
    1
    Vote Rating
    2
    infernoz is on a distinguished road

      0  

    Default


    I am missing something regarding the last comment related to store: { type: 'store' }

    I have the same exact issue as tangalla, and attempted to resolve the filtering taking affect on all instances of my combobox sharing the same store by specifying a store's alias. and then specifying store: {type: 'store'}. However this is not working for me and I am getting name not found errors from javascript. Can you give a hard example of how different store instances can be associated with different combobox instances?

    Another option is to do what tangalla has done

    Code:
    listeners:{focus:
    function(field, value){this.getStore().clearFilter()}
    }
    But I'm wondering if it makes more sense for the listener to be on select instead of focus. Everyones thoughts on this and my points above are greatly appreciated.

    Cheers,

    infernoz

  7. #7
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,770
    Answers
    355
    Vote Rating
    165
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      1  

    Default


    Here's an example where the store is defined one and an instance of it is used by two combos. The first one is filtered to show items starting with 'Ala'. The second is unaffected.

    Code:
    // The data store containing the list of states
    Ext.define('StatesStore', {
        extend: 'Ext.data.Store',
        alias: 'store.statesstore',
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
            //...
        ]
    });
    
    
    // Create the combo box, attached to the states data store
    var c1 = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: {
            type: 'statesstore'
        },
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    
    
    // Create the combo box, attached to the states data store
    var c2 = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: {
            type: 'statesstore'
        },
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    
    
    c1.getStore().filter('name', /^Ala/);

  8. #8
    Sencha User
    Join Date
    Jan 2012
    Location
    New York City
    Posts
    109
    Answers
    1
    Vote Rating
    2
    infernoz is on a distinguished road

      0  

    Default


    Thanks slemmon, much appreciated. Your example helped out.

    I do have one problem with this approach though. What if you are using a store that loads its data remotely? Every time you create a new combo box a new store instance is created and loaded from the server.

    Now this isnt inherentely a problem, but this can cause many many requests to be sent to the server depending on how many comboboxes are created. I also noticed that when I have a default value specified for the combobox, the value does not appear since when ExtJS is attempting to apply the value, the store hasnt completely loaded yet.

    Code:
    Ext.define('SomeComboBox', {
        extend: 'Ext.form.field.ComboBox',
        alias : 'widget.someComboBox',
        queryMode: 'local',
        tpl: new Ext.XTemplate('<tpl for=".">' + '<li style="height:25px;" class="x-boundlist-item" role="option">' + '{fieldDomainValue}' + '</li></tpl>'),
        store: {
            type: 'someStore' //store is loaded from server
        },
        displayField: 'fieldDomainValue',
        valueField: 'fieldDomainValue',
        value: 'SP',
        fieldLabel: 'ID Type',
        forceSelection: true,
        triggerAction: 'all'
    });
    Even setting a value with comboBox.setValue('ABC') doesnt work all the time until the store has loaded.

    Besides infinitely looping and calling store.isLoading() over and over, is there are way around this?

    Cheers,

    infernoz

  9. #9
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,770
    Answers
    355
    Vote Rating
    165
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      1  

    Default


    If you want to manage the calls to the server (you have lots of the same type of combo - that sort of thing) you might need to Ext.Ajax.request() the data down to your app and then store the response on a property / variable in your app and then have the combos load from that response directly instead of going to the server for their data.

    As for the defaultValue you can do something like:

    Code:
    combo.on({
        load: function () {
            combo.setValue(...);
        },
        single: true
    });
    Or, if you're using the MVC pattern you can set that up in a listener on a controller's control/listen method about the same way (without the single: true if set in the control/listen method).

  10. #10
    Sencha User
    Join Date
    Jan 2012
    Location
    New York City
    Posts
    109
    Answers
    1
    Vote Rating
    2
    infernoz is on a distinguished road

      0  

    Default


    Thanks again slemmon. After numerous failed attempts messing around with listeners for the stores and comboboxes, I used your suggestion of a standalone Ajax request to get the data I am looking for once, and then associating it with each instance of my combobox.

    For anyone interested, here is the general idea of what I'm doing in the code

    --Standalone Ajax request
    Code:
    var dataTypes = [];
    
    Ext.Ajax.request({
        url: '/mydomain/myurl.html',
        params: {'dataTypeToRetrieve': 'dataTypeImLookingFor'},
        success: function(response, opts) {
            var obj = Ext.decode(response.responseText);
            var dataArray = obj.data;
            for (var i = 0; i < dataArray.length; i++) {;
                dataTypes .push(dataArray[i]);
            }
        },
        failure: function(response, opts) {
            console.log('Could not get domain values due to status ' + response.status);
        }
    });
    --The Store, defined in same .js file as above Ajax call
    Code:
    Ext.define('MyApp.store.comboboxstore.StoreForComboBox', {
        extend: 'Ext.data.Store',
        alias : 'store.storeForComboBox',
        fields: ['fieldDomainValue'],
        data: dataTypes 
    });
    --Combobox
    Code:
    Ext.define('MyApp.view.issue.SomeComboBox', {
        extend: 'Ext.form.field.ComboBox',
        alias : 'widget.someComboBox',
        queryMode: 'local',
        tpl: new Ext.XTemplate('<tpl for=".">' + '<li style="height:25px;" class="x-boundlist-item" role="option">' + '{fieldDomainValue}' + '</li></tpl>'),
        store: {
            type: 'storeForComboBox'
        },
        displayField: 'fieldDomainValue',
        valueField: 'fieldDomainValue',
        value: 'SP',
        fieldLabel: 'ID Type',
        forceSelection: true,
        triggerAction: 'all'
    Thanks,

    infernoz

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar