需求是读取excel表头,动态的显示出来。。。。

 

html:

<td>模板上传:</td>
            <td class="text-left" style="width: 30%">
             <input type="file" class="form-control" data-required="1" name="file_name" >
             </td>

<table > </table> 

 

js:

$("#fileName").change(function(e){
  $.ajaxFileUpload({
  url: "***********",
  files: $(':file'),
  data: {},
  dataType: "json",
  contentType: 'text/json,charset=utf-8',
  success:function(data){
  if(data.length == 0){
  $('#file_examine').modal("show");
    $("#addTable").empty();
    alert("请检查读取的文件是否正确")
    return;
  }else{
    $('#dg').datagrid({
    columns:[[
      {field:'xh',
      title:' 序号 ',
      width:150,
    formatter: function(val,rec,index){
    return index + 1;
    }
  },{
    field:'name',
    title:'中文字段',
    width:200
  },{field:'isjm',
    title:'是否加密 ',
    width:100,

  },{
  checkbox:'true',
  field:'Encrypt',
    title:'是否加密',
  width:200
  }
  ]]
  });
  //easyui数据动态添加
  for(i=0;i<data.length;i++){
    $('#dg').datagrid('appendRow',{
    xh: 'new name',
    name: data[i],
    Encrypt: ''
  });
  }
  }
  },  
    error: function(data, status, e) {
      console.log("出现意外的错误")
  }
  });
})

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-01-27
  • 2021-12-14
相关资源
相似解决方案