dataTable与DataTable获取行数据,上传文件功能

zlscTable = $('#lxzlTable').dataTable({
    destroy: true,
    serverSide: true,
    responsive: true,
    processing:true,
    autoWidth: true,//自动计算列宽
    deferRender: true,//设置延迟渲染,提高效率用
    draw:false,
    searching : false, 
    bLengthChange: false,
    order: [ 0, 'asc' ],
    ajax: {
        url: "sjxm2/getLxzlInfoData",
        type: "POST",
        data : function(d) {  
            var sentJson = GET_SENT_JSON(d);
            sentJson.search1 = sjxmglArr[0].xmfldm.split('/')[0];
            sentJson.search2 = sjxmglArr[0].sjxmdm;
            return sentJson;
        },
        error: function (e) {
            ALERT_ERROR(zlscTable,e);
        },
    },
    lengthMenu: PAGELENGTH,
    "language": LANGUAGESETTING,
    columnDefs : [
        { "targets": 0 ,"name":"wdlx","title": "文档类型" ,"width": "10%" },
        { "targets": 1 ,"name":"wdmc","title": "文档名称" ,"width": "15%" },
        { "targets": 2 ,"name":"fj","title": "附件名(点击下载)" ,"width": "15%" },
        { "targets": 3 ,"name":"isby","title": "必要否" ,"width": "6%" ,orderable :false},
        { "targets": 4 ,"name":"is_zlsc","title": "资料生成" ,"width": "6%" ,orderable :false},
        { "targets": 5, "name":"lxzl_type", "title": "立项资料", "visible" : true, "width" : "15%", orderable : false },
        { "targets": 6 ,"name":"edit","title": "操作" ,"visible": true,"width": "20%"  ,orderable :false},
        { "targets": 7 ,"name":"wdbh","title": "文档编号" ,"visible": false,"width": "10%" , orderable :false ,},
        {
            "render": function ( data, type, row ) {
                var file = data.split(",");
                var result="";
                for(var i=0; i"  + file[i] + "
"; result += "" + file[i] + "
" } return result; }, "targets": [2], "visible": true }, { "render": function ( data, type, row ) { var result = ""; if(data == "1"){ result = "" + "是" + ""; }else{ result = "" + "否" + ""; } return result; }, "targets": [3], "visible": true }, { "render": function ( data, type, row ) { var result = ""; if(data == "1"){ result = "" + "是" + ""; }else{ result = "" + "否" + ""; } return result; }, "targets": [4], "visible": true }, ], columns: [ { data: 'wdlx' }, { data: 'wdmc' }, { data: 'fj' }, { data: 'isby' }, { data: 'is_zlsc' }, { "sClass": "text-center", "data": "lxzl_type", "render": function (data, type, row, meta) { var result = ""; var i = meta.row; result = ""; return result; }, }, //带下载 //{ data: null ,defaultContent: "  " }, { data: null ,defaultContent: "  " }, { data: 'wdbh' }, ] }); $('#lxzlTable tbody tr').live('click', function() { }); //鼠标移动添加背景颜色 mouseEvent("lxzlTable"); $("table#lxzlTable").on("change", "select", function(){ var jzszDataArr = []; var nRowmc = $(this).parents('tr')[0]; var aDatamc = zlscTable.fnGetData(nRowmc); //dataTable // var aDatamc = $('#lxzlTable').DataTable().row(this).data(); //dataTable // var aDatamc = lxzlTable.row(this).data() //DataTable rowNummc = $(this).parents('tr')[0].rowIndex - 1; }); //上传 $('#lxzlTable').on('click', '.upload', function (e) { uploadFiles(); return false; }); //文件上传 function uploadFiles() { form = $("
"); input1 = $(""); form.append(input1); form.appendTo("body") $("#fileName").click(); // 获取文件对象 // var file = $('#fileName')[0].files; // if (!file || file.length === 0) { // alert('请先选择文件'); // return false; // } else { // return file[0]; // } }; $('#uploadFile').live("change","#fileName",function(){ var file = $('#fileName')[0].files; var sjxm = sjxmglArr[0].sjxmdm; // 构建form数据 var formFile = new FormData; //把文件放入form对象中 for(var i=0; i

转载于:https://www.cnblogs.com/sunBinary/p/11592487.html

你可能感兴趣的:(dataTable与DataTable获取行数据,上传文件功能)