Results 1 to 3 of 3

Thread: store.filter or store.reload .. wheres the problem? (chained link combo boxes)

  1. #1

    Default store.filter or store.reload .. wheres the problem? (chained link combo boxes)

    Hi,

    I have the following code for the first combo:

    Code:
                field: {
                    xtype: 'combobox',
                    id: 'brand',
                    store: brands,
                    displayField: 'name',
                    valueField: 'id',
                    queryMode: 'local',
                    typeAhead: true,
                    forceSelection: true,
                    triggerAction: 'all',
                    viewConfig: {validateOnBlur: false},
                    selectOnFocus:true,
                    emptyText: 'Select brand',
                    listeners: {
                        select: { fn:function(combo, value) {
                                            console.log('changing the next combo');
                                            var modelDest = Ext.getCmp('model');
                                            console.log(modelDest.getValue());
                                            console.log(combo.getValue());
                                            modelDest.setDisabled(true);
                                            modelDest.setValue('');
                                            modelDest.store.removeAll();
                                            modelDest.store.filter('brand_id', combo.getValue());
                                            modelDest.store.reload({
                                                    params: { brand_id: combo.getValue() }
                                            });
                                            modelDest.setDisabled(false);
                                     }
                                },
                        scope: this
                    }
    The model used by second combo looks like this:

    Code:
    Ext.define('Model', {
        extend: 'Ext.data.Model',
        fields: [{
            name: 'id',
            type: 'int',
            useNull: true
        }, 'name','brand_id','lines']
    });
    and the store for this , below:

    Code:
        var models = Ext.create('Ext.data.Store',{
            autoLoad: true,
            autoSync: false,
            id: 1,
            extraParams: {
                    brand_id: ''
            },
            model: 'Model',
            restful: true,
            proxy: {
                    type: 'rest',
                    url: 'models/',
                    reader: {
                            type: 'json',
                            root: 'models'
                    },

    Problems below:

    1. if I use modelDest.store.filter('brand_id', combo.getValue()); in the listener, i get no results in the second combo
    2. if I use modelDest.store.reload({ in the listener, i get the following error message:
    "
    modelDest.store.reload is not a function"
    3. if I use model.Dest.store.load({ in the listener, the second combo box gets populated correctly, but when choosing a value, that value is set for all columns in the grid for the "model" combo box

    What am I doing wrong?

    Thanks,
    Dan

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449
    Answers
    3997

    Default

    Please post into the appropriate forum. I have moved this to the Ext JS 4 Q&A forum for you.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3

    Default

    Attached -- full version.
    I did some more changes, tweaking around with this and that, now it randomly clears out the Model column, and also randomly loading it back.

    Some help please?
    Attached Files Attached Files

Posting Permissions

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