Chosen is a jQuery plugin that makes long, unwieldy select boxes much more user-friendly.
https://harvesthq.github.io/chosen/
.net MVC下實(shí)裝小栗:
1.在對(duì)應(yīng)的Controller里準(zhǔn)備好數(shù)據(jù)源
比如:
ViewBag.専用場(chǎng)所CD = new SelectList(db.M_SenyouBasyos, "専用場(chǎng)所CD", "専用場(chǎng)所名", t10_備品臺(tái)帳.専用場(chǎng)所CD);
2.頁面綁定
Html.DropDownList("専用場(chǎng)所CD", null, new { @class = "chzn-select" })
@Html.ValidationMessageFor(model => model.専用場(chǎng)所CD)
3.配置chosen
$(".chzn-select").chosen(
{
no_results_text: "候補(bǔ)値が見つかりません:",
search_contains: true
});
$(".chzn-select-deselect").chosen({ allow_single_deselect: true, no_results_text: '候補(bǔ)値が見つかりません' });
4.想直接控制chosen的width?
用JS搞定:
$(".chosen-container").css("width", "100%");
posted on 2016-03-14 15:27
Ying-er 閱讀(3796)
評(píng)論(2) 編輯 收藏 所屬分類:
JQuery 、
.Net