将optgroups嵌套在dropdownlist / select中 [英] Nesting optgroups in a dropdownlist/select

查看:372
本文介绍了将optgroups嵌套在dropdownlist / select中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个客户c#DropDownList控件,它可以呈现出它的内容是optgroups(不是从头开始,我编辑了一些在网上找到的代码,尽管我完全理解它在做什么),并且它工作正常。 p>

然而,我现在遇到了一个情况,我需要在下拉菜单中有两个缩进级别,即

 <选择> 
< optgroup label =Level One>
< option> A.1< / option>
< optgroup label =Level Two>
< option> A.B.1< / option>
< / optgroup>
< option> A.2< / option>
< / optgroup>
< / select>

然而,据我所知,这只会像正常的optgroups一样呈现。



有没有办法产生这种嵌套行为?

解决方案

好的,如果有人永远读这个:最好的选择是在每个额外的缩进级别添加四个& nbsp; s,看起来似乎!



so:

< select> < optgroup label =Level One> <选项> A.1< / option> < optgroup label =& nbsp;& nbsp;& nbsp;& nbsp; Level Two> <选项>&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP; A.B.1< / option> < / OPTGROUP> <选项> A.2< / option> < / optgroup>< / select>

I have created a customer c# DropDownList control that can render out it's contents are optgroups (Not from scratch, I edited some code found on the internet, although I do understand exactly what it's doing), and it works fine.

However, I have now come across a situation where I need to have two levels of indentation in my dropdown, i.e.

<select>
    <optgroup label="Level One">
        <option> A.1 </option>
        <optgroup label="Level Two">
            <option> A.B.1 </option>
        </optgroup>
        <option> A.2 </option>
    </optgroup>
</select>

However, as far as I'm aware this will just render like normal optgroups.

Is there a way to produce this nested behaviour?

解决方案

Ok, if anyone ever reads this: the best option is to add four &nbsp;s at each extra level of indentation, it would seem!

so:

<select>
 <optgroup label="Level One">
  <option> A.1 </option>
  <optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;Level Two">
   <option>&nbsp;&nbsp;&nbsp;&nbsp; A.B.1 </option>
  </optgroup>
  <option> A.2 </option>
 </optgroup>
</select>

这篇关于将optgroups嵌套在dropdownlist / select中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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