两步教你如何自定义搜索表单

动态 未结 置顶 精帖 5 4566
admin
VIP1 2023-03-30 16:16:58
悬赏:0F币
此处已 backend/member/member/index.html 为例子 第一步 在 index.html 页面写一个搜索表单模板 [pre] <script type="text/html" id="form"> <fieldset id="searchFieldList_list" class="layui-elem-field table-search-fieldset"> <legend>搜索</legend> <form class="layui-form" id="layui-form-list"> <div class="layui-row"> <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3"> <div class="layui-form-item layui-inline "> <label class="layui-form-label layui-col-xs4">ID</label> <div class="layui-input-inline layui-col-xs8"> <input lay-filter="id" id="field_id" name="id" data-search="true" data-searchop="%*%" value="" placeholder="输入ID" class="layui-input "> </div> </div> </div> <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3"> <div class="layui-form-item layui-inline "> <label class="layui-form-label layui-col-xs4">名称 </label> <div class="layui-input-inline layui-col-xs8"> <input lay-filter="username" id="field_username" name="username" data-search="true" data-searchop="%*%" value="" placeholder="输入名称 " class="layui-input "> </div> </div> </div> <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3"> <div class="layui-form-item layui-inline"> <label class="layui-form-label layui-col-xs4 ">性别</label> <div class="layui-input-inline layui-col-xs8"> <select lay-filter="sex" class="layui-select " id="field_sex" name="sex" data-search="select" data-searchop="="> <option value="">-全部 -</option> <option value="0">保密</option> /n <option value="1">男</option> /n <option value="2">女性</option> /n</select> </div> </div> </div> <div class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg3"> <div class="layui-form-item layui-inline"> <label class="layui-form-label layui-col-xs4">注册时间</label> <div class="layui-input-inline layui-col-xs8"> <input id="field_create_time" name="create_time" lay-filter="timePicker" data-timetype="datetime" data-searchdateformat="yyyy-MM-dd" data-timepickerformat="YYYY-MM-DD HH:mm:ss" data-search="range" data-searchop="range" value="" placeholder="输入注册时间" class="layui-input "> </div> </div> </div> <div class="layui-form-item layui-inline" style="margin-left: 80px;"> <button type="submit" class="layui-btn layui-btn-normal" data-type="tableSearch" data-tableid="list" lay-submit="submit" lay-filter="list_filter">搜索 </button> <button type="reset" class="layui-btn layui-btn-primary" data-type="tableReset" data-tableid="list" lay-filter="list_filter">重置 </button> </div> </div> </form> </fieldset> </script> [/pre] 第二步 在member.js 里设置 searchFormTpl: 'form', form 即是上面script 的id [pre] Table.render({ elem: '#' + Table.init.table_elem, id: Table.init.tableId, searchFormTpl: 'form', }); [/pre]
回帖
  • 2023-03-31 18:18:22
    发帖回复删不了啊~报bug
    0 回复
  • 2023-03-31 18:17:52
    老板,论坛代码显示这个问题~~~得解决啊!
    0 回复
  • 2023-03-31 18:13:21
    老板,论坛代码显示这个问题~~~得解决啊!
    0 回复
  • 2022-11-29 01:01:03
    打开默认隐藏 [pre] &lt;fieldset id=&quot;layui-search-field-list&quot; class=&quot;layui-elem-field table-search-fieldset layui-hide&quot;&gt; [/pre]
    0 回复
  • 2022-04-22 15:24:02
    谢谢楼主分享,已测试,可以用
    1 回复
本周热议