web123456

layui's table searchable drop-down box (select)

  • <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:'Zhang San1',age:23,state:1});
  • data.push({id:2,name:'Zhang San 2',age:23,state:1});
  • data.push({id:3,name:'Zhang San 3',age:23,state:1});
  • data.push({id:3,name:'Zhang San 4',age:23,state:0});
  • data.push({id:4,name:'Zhang San 5',age:23,state:0});
  • data.push({id:6,name:'Zhang San 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: 'Name',width:150}
  • ,{field:'age', title: 'Age',width:305}
  • ,{field:'state', title: 'Fault status',width:90,event:'addState',templet:function (d) {
  • if( == 0){
  • return 'Anomalies';
  • }else if( == 1){
  • return 'Normal';
  • }else {
  • return 'Anomalies';
  • }
  • }}
  • ]]
  • });
  • var selectParams = [];
  • ({name:'1',value:'Test 1'});
  • ({name:'2',value:'Test 2'});
  • ({name:'3',value:'Test 3'});
  • ({name:'4',value:'Test 4'});
  • ({name:'5',value:'Test 5'});
  • ({data:selectParams,layFilter:'tableEvent',event:'addSelect'});
  • ({url:'',where:{},layFilter:'tableEvent',event:'addState'});
  • });
  • </script>