https://github.com/davidstutz/bootstrap-multiselect
"~/Content/bootstrap-multiselect.css"
"~/Scripts/bootstrap-multiselect.js",
SelectList作成
foreach (MemberModel m in ls)
{
SelectListItem item = new SelectListItem()
{
Value = m.LoginUserId,
Text = m.UserName,
};
lsMember.Add(item);
}
ViewBag保存
ViewBag.AllChkMember = bizTown.GetChkMembers();
初始化
$('#editMembers,#editCustomerMembers').multiselect({
// ====== 日本語化 ====== start ======
selectAllText : 'すべて' ,
filterPlaceholder: '検索' ,
nonSelectedText : '未選択' ,
nSelectedText : '# 個選択',
allSelectedText : '全選択' ,
// ====== 日本語化 ====== end ======
// 氏名の表示数設定
numberDisplayed: 5,
// Group表示
enableCollapsibleOptGroups: true,
// Group初期Close状態に設定
collapseOptGroupsByDefault: true,
// 検索機能Open
enableFiltering: true
});
<style>
.ui-multiselect {
line-height: 30px;
min-width: 200px;
}
</style>
引用
@Html.ListBoxFor(model => model.SecChkArr, ViewBag.AllChkMember as IEnumerable<SelectListItem>, new { @id = "editMembers", @class = "multiselect form-control", multiple = "multiple" })
注:SecChkArr是数组
posted on 2018-05-24 15:36
Ying-er 阅读(766)
评论(0) 编辑 收藏 所属分类:
JQuery 、
.Net