views:

43

answers:

1

Below is a sample of a filteringSelect populated with user data. My goal is to have perform wilcard match on the displayed values. for example, if the user types 'son', the dropdown matches will be "homer simpSON' and 'carl calSON'. By default, the match will only be on the beginning of the label.

I tried changing dijit.byId('userselect').searchAttr, but setting it to anything but a string causes erronious behaviour.

<input id="userselect">

<script type="text/javascript">
    dojo.require("dijit.form.FilteringSelect");
    dojo.require("dojo.data.ItemFileReadStore");

    var user_data = {
        "itentifier":"user_id",
        "label":"label",
        "items":[
            {"first_name":"Waylon","last_name":"Smithers","label":"Waylon Smithers","user_id":7}
            ,{"first_name":"Carl","last_name":"Carlson","label":"Carl Carlson","user_id":6}
            ,{"first_name":"Homer","last_name":"Simpson","label":"Homer Simpson","user_id":4}
            ,{"first_name":"Lenny","last_name":"Leonard","label":"Lenny Leonard","user_id":5}
            ,{"first_name":"Montgomery","last_name":"Burns","label":"Montgomery Burns","user_id":8}
            ]
        };

    dojo.addOnLoad(function() {
        var userStore = new dojo.data.ItemFileReadStore({
            //url: "/user/lookup",
            data: user_data
        });
        var filteringSelect = new dijit.form.FilteringSelect({
            id: "userselect",
            name: "userselect",
            store: userStore,
            searchAttr: 'label' //["first_name", "last_name", "oasis"]
        },
        "userselect");
    });
</script>
A: 

Have a look at queryExpr

kalkin
queryExpr works, but now the matching behavior is wrong:Suppose I begin typing 'simpson', the first character 's' now matches 'Waylon Smithers". The combo field populates with 'Waylon Smithers', but the highlighting is wrong. As I keep typing 'imson' it merges into the selected text as "wimpson" and then doesn't match. Is this a bug in dojo?
AntiEgo
As far as i understand you you have to set it to *${0}. Have you did it?
kalkin