Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何将div元素添加到";aocolumn";数据表的_Jquery_Html_Datatables - Fatal编程技术网

Jquery 如何将div元素添加到";aocolumn";数据表的

Jquery 如何将div元素添加到";aocolumn";数据表的,jquery,html,datatables,Jquery,Html,Datatables,如何将progressBarDiv添加到datatable的status列。在status列中,我试图显示progressbar。我怎样才能做到这一点 有人能帮我解决这个问题吗 我的html: <html> <body> <div id="progressBarDiv"></div> <script> var currentPath = null; var options = { "bPro

如何将progressBarDiv添加到datatable的status列。在status列中,我试图显示progressbar。我怎样才能做到这一点

有人能帮我解决这个问题吗

我的html:

<html>
<body>
<div id="progressBarDiv"></div>
<script>
    var currentPath = null;
       var options = {
            "bProcessing": true,
            "bServerSide": false,
            "bPaginate": false,
            "bAutoWidth": false,
             "sScrollY":"250px",
          "fnCreatedRow" :  function( nRow, aData, iDataIndex ) {
        if (!aData.IsDirectory) return;
        var path = aData.Path;
        $(nRow).bind("click", function(e){
            $.get('/files?path='+ path).then(function(data){
                table.fnClearTable();
                table.fnAddData(data);
                currentPath = path;
            });


            $.get('/directory?path='+ path).then(function(data){        
                $("input[name='location']").val(data.directory);

             });         
            e.preventDefault();
            });
        },
        "aoColumns": [{"sTitle":"File Name", "mData": null, "bSortable": false, "sClass": "head0", "sWidth": "55px",
                "render": function (data, type, row, meta) {
                  if (data.IsDirectory) {
                    return "<a href='#' target='_blank'><i class='fa fa-folder'></i>&nbsp;"  + data.Name +"</a>";
                  } else {
                    return "<a href='/" + data.Path + "' target='_balnk'><i class='fa " + getFileIcon(data.Ext) + "'></i>&nbsp;" + data.Name +"</a>";
                  }
                }
              },
                {"sTitle":"Date",align: 'Center', "mData": null, "bSortable": false, "sClass": "head1", "sWidth": "75px",
                "render": function (data, type, row, meta) {
                  if (data.IsDirectory) {
                     return  data.Date;
                 }else{
                   return data.Date;

                 } 
                }
              },


            {"sTitle":"Status",align: 'Center', "mData": null, "bSortable": false, "sClass": "head1", "sWidth": "55px",
                "render":socket.on( 'message',   function (data, type, row, meta) {

                        console.log(data);

                  if (data.IsDirectory) {
                     return data.percent;
                 }else{
                   return data.percent;

                 }
                })

              }
            ]   
         };
        socket.on('disconnect', function(){})

      var table = $(".linksholder").dataTable(options);
</script>
</body>
</html>

var currentPath=null;
变量选项={
“bProcessing”:正确,
“bServerSide”:false,
“bPaginate”:错误,
“bAutoWidth”:假,
“sScrollY”:“250px”,
“fnCreatedRow”:函数(nRow、aData、iDataIndex){
如果(!aData.IsDirectory)返回;
var path=aData.path;
$(nRow).绑定(“单击”,函数(e){
$.get('/files?path='+path)。然后(函数(数据){
table.fnClearTable();
表fnAddData(数据);
currentPath=路径;
});
$.get('/directory?path='+path)。然后(函数(数据){
$(“input[name='location']”)val(data.directory);
});         
e、 预防默认值();
});
},
“aoColumns”:[{“sTitle”:“文件名”,“mData”:null,“bSortable”:false,“sClass”:“head0”,“sWidth”:“55px”,
“呈现”:函数(数据、类型、行、元){
if(data.IsDirectory){
返回“”;
}否则{
返回“”;
}
}
},
{“sTitle”:“Date”,align:“Center”,“mData”:null,“bSortable”:false,“sClass”:“head1”,“sWidth”:“75px”,
“呈现”:函数(数据、类型、行、元){
if(data.IsDirectory){
返回数据。日期;
}否则{
返回数据。日期;
} 
}
},
{“sTitle”:“Status”,align:“Center”,“mData”:null,“bSortable”:false,“sClass”:“head1”,“sWidth”:“55px”,
“呈现”:socket.on('message',函数(数据、类型、行、元){
控制台日志(数据);
if(data.IsDirectory){
返回数据0.5%;
}否则{
返回数据0.5%;
}
})
}
]   
};
socket.on('disconnect',function(){})
变量表=$(“.linksholder”).dataTable(选项);

如果aoColumns渲染属性适合您,我建议您继续使用这些属性。请确保为每个进度条指定一个唯一的ID,可能具有类似于“progressBar”的命名约定。

您是否打算让表中的每一行在progressBar上具有完全相同的值?我猜您希望在这里为每一行显示不同的“进度值”。无论哪种方式,我认为您都需要在每行的基础上定义进度条,而不是试图在每行中呈现相同的进度条。也许您可以稍微澄清一下您的意图,并解释为什么要在多行中使用同一个div(我认为这是不可能或不可取的,特别是因为该div定义了一个id属性,该属性在文档中应该是唯一的)。是的,我正试图在每行中相应地保留不同的进度条值。