0

Surely it should be possible to issue the same query against the same store to populate a dGrid (or any other form of grid) and the dropdown in a filteringSelect with the same rows.

However it looks like the filteringSelect needs a response of the form

{
    "identifier": "abbreviation",
    "label": "name",
    "items": [
        { "abbreviation": "AL", "name": "Alabama" },
        { "abbreviation": "AK", "name": "Alaska" },

        { "abbreviation": "WY", "name": "Wyoming" }
    ]
}

and the dgrid needs 
[
        { "abbreviation": "AL", "name": "Alabama" },
        { "abbreviation": "AK", "name": "Alaska" },

        { "abbreviation": "WY", "name": "Wyoming" }
]

It seems that the identifier and label attributes coming from the store are completely superflous because you are getting the identifier via the identity API and in any case you can specify everything when you instantiate the filteringselect.

Yes I know there are work-arounds - I could use two different stores or queries and get the server-side to generate generate both of these based on some parameter in the query. But if I do this will the changes propagate properly when I make changes via the dgrid? or I could wrap the store API with something that puts the extra fields on the front of the response and pass the wrapped store into the filteringselect, but is there a simpler way?

1 Answer 1

0

Use your array to create a data store like:

var store = Observable(new Memory({ 
    idProperty: "abbreviation", 
    data: [ { 
        "abbreviation": "AL", "name": "Alabama" 
    }, { 
       "abbreviation": "AK", "name": "Alaska" 
    }, { 
      "abbreviation": "WY", "name": "Wyoming" 
    }]
 }));

Then, your can set this store to dgrid as :

dgrid.set('store', store);

For your filteringSelect, you can set this store as

new FilteringSelect({ 
    searchAttr:"name", 
    store: store 
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.