1 Star 0 Fork 7

aimu2000/Layui-component_1

forked from Hg科技/Layui-component 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dropdownTable-example.html 2.54 KB
一键复制 编辑 原始数据 按行查看 历史
Hg科技 提交于 2024-05-13 21:22 +08:00 . 支持选中回调函数,支持弹窗关闭
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>下拉表格组件使用演示</title>
<link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
<div class="layui-container" style="margin-top:20px">
<blockquote class="layui-elem-quote" style="margin-top:50px;">
<legend>下拉表格-使用示例 </legend>
</blockquote>
<form class="layui-form">
<div class="layui-form-item">
<label class="layui-form-label" for="name">姓名</label>
<input type="hidden" name="name" id="name" data-display-value="王五" value="1" />
<div class="layui-input-block">
<a id="genderSelect"></a>
</div>
</div>
</form>
</div>
<script src="layui/layui.js"></script>
<script>
layui.config({
base: 'layui-exts'
}).extend({
'dropdownTable': '/dropdownTable/dropdownTable'
});
layui.use(['dropdownTable', 'jquery'], () => {
let dropdownTable = layui.dropdownTable,
layer = layui.layer,
$ = layui.jquery;
dropdownTable.render({
emptyMsg: '请选择人员',
elem: "#genderSelect",
bindInput: "#name", //结果集绑定到对应的input上,多选为$符号分割的值
selectType: 'checkbox', //支持单选和多选,默认为单选,值:checkbox【多选】、radio【单选】
searchName: 'keyWords', //搜索框提交key,默认为keyWords
needPopup: true, //是否需要弹窗选择方式,默认为true,会在后自动添加选择按钮,如需要关闭,请改为false
selectTable: {
uniqueId: 'id',
displayField: 'username',
//具体可参考layui的table模块,和table模块的保持一致
cols: [[
{ field: 'id', title: 'ID' },
{ field: 'username', title: '用户' },
{ field: 'sex', title: '性别' },
{ field: 'city', title: '城市' }
]],
data: [
{ "id": "1", "username": "王五", "sex": "", "city": "浙江杭州" },
{ "id": "2", "username": "三甲", "sex": "", "city": "浙江杭州" },
{ "id": "3", "username": "李四", "sex": "", "city": "浙江杭州" }
],
page: true,
limit: 2
},
//选中行的ID集合,可结合自身业务,去后台获取自己完整的数据
onSelected: (ids) => {
console.log(ids);
}
});
});
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/aimu2000/layui-component_1.git
git@gitee.com:aimu2000/layui-component_1.git
aimu2000
layui-component_1
Layui-component_1
master

搜索帮助