Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.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
Javascript 使用datatables jquery将数据插入特定列单元格_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript 使用datatables jquery将数据插入特定列单元格

Javascript 使用datatables jquery将数据插入特定列单元格,javascript,jquery,datatables,Javascript,Jquery,Datatables,我已经搜索了数据表的文档,了解了如何在这里向表中添加数据 但我找不到一种方法将数据插入给定列的单个单元格中。例如,我需要像这样的东西: "columns": [ {target (0), "value which will be inserted"} ] if this date column (from the table) == json object date then put it there 有一种方法可以从数组中插入数据,但是数组的每个部分都包含整行的值,请参见此处,但是我需

我已经搜索了数据表的文档,了解了如何在这里向表中添加数据 但我找不到一种方法将数据插入给定列的单个单元格中。例如,我需要像这样的东西:

 "columns": [ {target (0), "value which will be inserted"} ]
 if this date column (from the table) == json object date then put it there
有一种方法可以从数组中插入数据,但是数组的每个部分都包含整行的值,请参见此处,但是我需要将数据插入到与列相关的不同单元格中,因为我最初不知道列标签。这是因为数据将采用json格式,首先我需要提取每个json对象的唯一日期。这些将是我的列标题。然后,对于基于日期的每个对象,我需要将其放入相关的日期列中。所以逻辑应该是这样的:

 "columns": [ {target (0), "value which will be inserted"} ]
 if this date column (from the table) == json object date then put it there

谢谢

经过大量研究后,这项功能似乎在DataTables中不可用。这就是为什么我用jQuery解决了这个问题。使用下面的代码,我可以遍历列并在其中插入值

//change 1 to the column at hand
$("#table tr > :nth-child(1)").each(function(index) {
    //skip the column header
    if (index > 0){
        //insert value
        $(this).html("<span class='fixed-size-square'> value to be inserted");
    }
});

向我们展示表的某些部分,以及您想要设置的数组。数据将采用json格式,首先我需要提取每个json对象的唯一日期。这些将是我的列标题。然后,对于每个基于日期的对象,我需要将其放入相关列中。您是否也可以粘贴表的结构我还没有表的结构。我只是在想我该怎么做。使用api来设置/获取数据。如果进行了任何排序或分页,您的方法将失败,因为插件无法识别您的html更改。看见