dojo select set maximum width

风流意气都作罢 提交于 2020-01-15 03:51:15

问题


i have a problem with the width of my dojo select. The option of the select widget are filled by an ajax call. A few of the labels are very long and the width of the select widget grows with the large of the label. Is there a way to set the maximum width of the select widget? So that the width don't grow over 180px? PS: I implement the widget by programmatically way like

new Select({
    name: "select2"
}).placeAt(win.body())

Edit: Here for example http://jsfiddle.net/5r3gR/3/ when i select the "VeryVeryVeryLongLabel" the width of the select dijit changes but it should stay at the width.


回答1:


I used the claro theme with the added rule of...

.dijitSelectLabel {
    text-align:left;
    overflow: hidden;
    width:100px;
}

Which makes the width of the textbox static at 100px. The dropdown options will still expand out to the biggest width of your option

JSFiddle

To style different selects with different widths make the following changes

Css

.bigSelect .dijitSelectLabel {
    text-align:left;
    overflow: hidden;
    width:200px;
}

.smallSelect .dijitSelectLabel {
    text-align:left;
    overflow: hidden;
    width:100px;
}

Code

var big = new Select({
    store: os,
    class: "bigSelect"
}, "target");

var small = new Select({
    store: os,
    class: "smallSelect"
}, "target");

JSFiddle



来源:https://stackoverflow.com/questions/24640101/dojo-select-set-maximum-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!