用 data的 简单的 jquery datatable

 

1-1.egg- [[]]

 
var resdata= [

  [1231,2323,32323,2423,1],

  [1231,2323,32323,2423,1]

  ]

 
var col_s1=''
      for(var item of resdata.columns){
        col_s1+='<th>'+item+'</th>'
      }
      $("#"+"dv_data03").html("<table class='data03a'><thead><tr>"+col_s1+"</tr></thead></table>")

$('#table1').dataTable({

  data:resdata,

  //columns: [{render:function(data){...} ... }]

  bSort: false,

  bInfo: false,

  bPaginate: false,

  searching: false,

})

 

2.egg [{}]

 
    var resdata={columns:['a','b','c']}
    var data03 = [
        {
          a: "fwep",
          b:'12f',
          c:'12e',
          d:'12e',
        }]

      var col_s1=''
      var cols=[]
      for(var item of resdata.columns){
        col_s1+='<th>'+item+'</th>'
        cols.push({data: item })
      }
 
      $("#"+"dv_data03").html("<table><thead><tr>"+col_s1+"</tr></thead></table>")
 
      $("#"+"dv_data03>table").DataTable({
        data: data03,
        columns: cols,
        bLengthChange: false,
        searching: false,
        bPaginate: false,
        info:false,
        destroy:true,
      });
posted @ 2020-01-09 17:48  以函  阅读(144)  评论(0编辑  收藏  举报