开发者

How to control Dojo FilteringSelect default rendering?

I have a dojo dijit.filering.select that populates with values from a dojo.data.ItemFileReadStore. Everything is working fine except I would like the filtering select to automatically get populated with the first value in the itemFileReadStore. Currently it is loading them as a list of options that are revealed when you click the down arrow, as per spec. I would instead like filteringSelect to be loaded with the first value. How do I do this? For some reason I cant figure it out. Any help would be hugely appreciated!

Kind Regards Nic开发者_高级运维k Frandsen

<script type="text/javascript">
        function updateOptions(){
            var itemId = dijit.byId("item_select").attr("value");
            var jsonStore = new dojo.data.ItemFileReadStore({ url: "/options/get-options-json/itemId/" + itemId });
            optionSelect.attr("store", jsonStore);
        }
</script>
<select dojoType="dijit.form.FilteringSelect"
        name="option_select"
        id="option_select"
        labelAttr="name"
        required="true"
        jsId="optionSelect">
</select>


It's has the feeling of a hack to me (not to mention a bit late for you) but I did this to achieve the same thing:

var valueSet = false;
filteringSelect.store.fetch({
    query:{ id:"*" },
    onItem : function(item, request) {
        if (!valueSet) {
            filteringSelect.setValue(request.store.getValue(item, "id"));
            valueSet = true;
        }
    }
});


This might work:

optionSelect.attr('displayedValue', itemLabel);

Where itemLabel is the label of the item you wish displayed (will depend on what your datastore looks like internally). That should set both the textbox content and the hidden field (with the corresponding itemValue).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜