【问题标题】:dual list box disabled selection option双列表框禁用选择选项
【发布时间】:2018-11-08 01:53:42
【问题描述】:

我正在使用从 http://www.virtuosoft.eu/code/bootstrap-duallistbox/ 获得的 Bootstrap Dual Listbox

我正在使用 Thymeleaf 生成列表框选项。我有这样一个场景——在我的 Entity 中有 BOOLEAN 列名 is_generated, 如果 'is_generated=true' 意味着需要禁用基于条件的选项,这意味着用户无法选择特定选项,例如 HTML 属性 (disabled="true")

这是我的代码

 <form id="chargeslistformid" method="post" action="#" 
				 th:action="@{/savechargeslist}" th:object="${wrpAssignCharges}">
         
        <label>
            <select id="selectBox" multiple="multiple"
            name="selectedChargesList" class="selectpicker form-control" >
                <option  th:each="charge:${chargeslist}" 
                th:value="${charge.pkAssignId}" 
                th:text="${charge.chargeName}"
                th:selected="${previouslist.contains(charge)}"></option>
            </select>
        </label>
        
       
        
        <br/>
        <button id="chargeslistbtnid" th:type="submit" class="btn btn-info">Next</button>
    </form>

请帮帮我...在此先感谢

【问题讨论】:

    标签: html thymeleaf bootstrap-duallistbox


    【解决方案1】:

    您可以使用 th:disabled 属性根据条件生成禁用属性:

    <option
      ..
      th:disabled="${ /* condition, e.g. 1 < 2 or #object.property == ... */ }"
    >
    </option>
    

    【讨论】:

    • 谢谢弗洛克,我会试试这个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    相关资源
    最近更新 更多