开发者

How to change order of elements in a dijit.form.Select

I'm using Dojo 1.5 to create a dijit.form.Select with some data from a datastore. The issue I'm finding is that I want the select to show the elements ordered by the identifier, but the select is ginving them ordered by the label. How can I avoid this behaviour?. Another issue I'm finding is that when I set the store, I initialized the store to select one of the elements, but it is selecting the first one. The code is a follows:

dojo.require("dijit.form.Select");
dojo.require('dojo.data.ItemFileReadStore');

dojo.addOnLoad(function(){

var boxContent = {"identifier":"idBox","items":[{"accessLevel":"FULL_ACCESS",
"boxName":"My Documents","boxType":"PERSONAL","idBox":1512,"numberFiles":9,
"userDisplayName":"Jose Luis Martinez A开发者_开发知识库vial","userName":"MIAMARA"},
{"accessLevel":"FULL_ACCESS","boxName":"12312312","boxType":"PERSONAL",
"idBox":17100,"numberFiles":0,"userDisplayName":"Jose Luis MartinezAvial",
"userName":"MIAMARA"}],"label":"boxName"};

var myStore = new dojo.data.ItemFileReadStore({data: boxContent });

var   boxCombo= new dijit.form.Select({
    name: 'select2' }).placeAt(dojo.body());
   boxCombo.setStore(myStore,1512);

})

It is available in http://jsfiddle.net/m9ucX/1/

Thanks for your help.


Just in case anyone comes looking, this question was also asked (and has been answered) on the dojo-interest mailing list:

I think you'll get what you want if you just set sortByLabel: false on your Select.

Source:
http://mail.dojotoolkit.org/pipermail/dojo-interest/2011-February/052328.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜