Results 1 to 2 of 2

Thread: How to use combo "publishes" value & bindings to filter store on another combo

  1. #1
    Sencha Premium User
    Join Date
    Jun 2011
    Location
    Perth, Western Australia
    Posts
    182
    Answers
    10

    Default Answered: How to use combo "publishes" value & bindings to filter store on another combo

    I have seen an example of using a combo's publishes: 'value' << as a filter on another combo's store with queryMode: 'remote'

    Is it possible to do this or have I got the wrong end of the stick?

    A user chooses an item from a combo. Let's say valueField is "ItemID".
    The selected record has another field (let's call it "ItemTypeID") with a value that I require to filter the next combo on the form.

    Is it possible to somehow publish the ItemTypeID value? & then using binding, filter another combo on the form by that value.

    This below isn't working for me ... I am putting it here to show an example of what I am attempting to do.



    Code:
    {
        reference: 'itemsList',
        xtype: 'combo',
        queryMode: 'local',
        displayField: 'ItemName',
        valueField: 'ItemID',
        publishes: ???? 'selection.data.ItemTypeID' ???? 
        fieldLabel: 'Choose Item',
        bind: {
            store: '{items}',
            value: '{current.checklistRec.ItemID}'
            }
    },
    {
        reference: 'checklist',
        xtype: 'combo',
        queryMode: 'local',
            displayField: 'ChecklistName',
        valueField: 'ChecklistID',
        fieldLabel: 'Checklist',
        bind: {
            store: '{checklists}',  <<<<<<<<<<<<<<<< Filter this store by '{selection.data.ItemTypeID}'
            value: '{current.checklistRec.ChecklistID}'
        },
    }
    for example... in the ViewModel the checklist store has this ..

    Code:
    stores: { 
    ...,
    ...,
       checklists: {
        type: 'checklists',
        filters: {
            property: 'ItemTypeID',
            value: '{itemsList.selection.data.ItemTypeID}' <<< Hoping this will dynamically filter the checklist Store on change of Item combo selection ... 
            }
       },
    ..
    }

  2. I think I got it sorted...

    It looks like the only thing I needed to do was apply the filter in the way shown below...
    (using the combo's reference ('itemsList') & it's 'selection' property)

    Code:
    stores:{
            checklists: {
                type: 'checklists',
                filters: {
                    property: 'ItemTypeID',
                    value: '{itemsList.selection.ItemTypeID}'  // << reacts dynamically to ItemsList combo change
                }
            }
        }
    Important to remove the "data" from Dot.Path >>> value: '{itemsList.selection.data.ItemTypeID}'

    It seems that I didn't need the "publishes" property on the Items combo after all.

  3. #2
    Sencha Premium User
    Join Date
    Jun 2011
    Location
    Perth, Western Australia
    Posts
    182
    Answers
    10

    Default

    I think I got it sorted...

    It looks like the only thing I needed to do was apply the filter in the way shown below...
    (using the combo's reference ('itemsList') & it's 'selection' property)

    Code:
    stores:{
            checklists: {
                type: 'checklists',
                filters: {
                    property: 'ItemTypeID',
                    value: '{itemsList.selection.ItemTypeID}'  // << reacts dynamically to ItemsList combo change
                }
            }
        }
    Important to remove the "data" from Dot.Path >>> value: '{itemsList.selection.data.ItemTypeID}'

    It seems that I didn't need the "publishes" property on the Items combo after all.

Similar Threads

  1. How to fix Ext.List "update" bindings when store has associations
    By luismerino in forum Sencha Touch 2.x: Q&A
    Replies: 4
    Last Post: 6 Mar 2012, 2:19 PM
  2. Replies: 1
    Last Post: 29 Sep 2011, 6:21 AM
  3. Replies: 3
    Last Post: 14 Dec 2010, 10:22 PM

Posting Permissions

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