如何更改dijit.form.Select中元素的顺序 [英] How to change order of elements in a dijit.form.Select

查看:135
本文介绍了如何更改dijit.form.Select中元素的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Dojo 1.5,从数据存储区创建一个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 Avial","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);

})

它可以在 http://jsfiddle.net/m9ucX/1/ 中找到

感谢您的帮助。

推荐答案

只要有人来看,还在dojo兴趣的邮件列表上询问(并已被回答)stion:

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


我想你会得到你想要的您只需在
上选择sortByLabel:false,然后选择。

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

资料来源:

http://mail.dojotoolkit.org/pipermail/dojo-interest/2011-二月/052328.html

这篇关于如何更改dijit.form.Select中元素的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆