单选用剃须刀选择

时间:2014-11-17 20:20:55

标签: razor jquery-chosen

所以我已经使用我的项目实现了Chosen并且在多选中工作得很好,但是我希望为简单的下拉列表添加它。我在下拉列表中总共有80个条目,因此需要选择的搜索功能。这是我的代码。

<div class="editor-label">

                         <span style="color: red;">*</span> <strong>Select Therapist:</strong>
                     </div>
                    <div class="editor-field">

            @Html.DropDownList("TherapistList", Model.TherapistList

     , new

     {

         @class = "chzn-select",
         data_placeholder = "Choose  Therapist",


     }
     )
        </div>

<script >

    $(".chzn-select").chosen({
        allow_single_deselect: false,
        search_contains: false,
        no_results_text: "Oops, nothing found!"
    });

</script>

我在顶部添加了CSS和.JS参考。当我添加@Html.ListBox("TherapistList", Model.TherapistList

时,它与multiselet一起工作正常

但我想在网站上显示带搜索选项的单选。

提前感谢。

1 个答案:

答案 0 :(得分:1)

如果你没有调用@ Html.Listbox而是@Html.DropDown,你将会选择一个选择。

@Html.DropDownList("TherapistList", Model.TherapistList, new {
     @class = "chzn-select",
     data_placeholder = "Choose  Therapist",
   }
)