layui的table可搜索下拉框(select)

时间:2024-12-10 16:47:48
  • <table class="layui-hide" id="tableId" lay-filter="tableEvent"></table>
  • <script>
  • layui.use(['table','layuiTableColumnSelect'], function () {
  • var table = layui.table;
  • var layuiTableColumnSelect = ;
  • var data=[];
  • data.push({id:1,name:'张三1',age:23,state:1});
  • data.push({id:2,name:'张三2',age:23,state:1});
  • data.push({id:3,name:'张三3',age:23,state:1});
  • data.push({id:3,name:'张三4',age:23,state:0});
  • data.push({id:4,name:'张三5',age:23,state:0});
  • data.push({id:6,name:'张三6',age:23,state:0});
  • table.render({
  • elem: '#tableId'
  • ,id:'id'
  • ,data:data
  • ,height: 'full-90'
  • ,page: true
  • ,cols: [[
  • {type:'checkbox'}
  • ,{field:'name',event:'addSelect',title: '名称',width:150}
  • ,{field:'age', title: '年龄',width:305}
  • ,{field:'state', title: '故障状态',width:90,event:'addState',templet:function (d) {
  • if( == 0){
  • return '异常';
  • }else if( == 1){
  • return '正常';
  • }else {
  • return '异常';
  • }
  • }}
  • ]]
  • });
  • var selectParams = [];
  • ({name:'1',value:'测试1'});
  • ({name:'2',value:'测试2'});
  • ({name:'3',value:'测试3'});
  • ({name:'4',value:'测试4'});
  • ({name:'5',value:'测试5'});
  • ({data:selectParams,layFilter:'tableEvent',event:'addSelect'});
  • ({url:'',where:{},layFilter:'tableEvent',event:'addState'});
  • });
  • </script>