简体   繁体   English

如何在jquery数据表上水平汇总每个特定的渲染行

[英]how to sum each specific rendered row horizontally on jquery datatable

I get data for datasrc from sql query and I display for each column using我从 sql 查询中获取 datasrc 的数据,并使用

"data": "attribute", "name": "name",
                    "render": function (data, type, full, meta) {}

I can't get calculate value from sql query, I have to get each rendred value of specific row to sum and put the result in each column horizontally exemple bellow of eachrow : row 1 col1 + row 1 col2 + row 1 col3 and put te result in row 1 col4我无法从 sql 查询中获取计算值,我必须将特定行的每个渲染值求和并将结果水平放置在每列中,例如每行的波纹管:第 1 行 col1 + 第 1 行 col2 + 第 1 行 col3 并放入 te导致第 1 行 col4

and the same for all horizontal ligne.和所有水平线一样。

Rows                  Col1        Col2      Col3    Col4  col5      col6      col7 
1                      12         1         23       36    string    string   string
2                       1         0          5       6     string    
3                       6         2          9       16    string    

for this jquery datatable serverside Showing 1-10:对于这个jquery数据表服务器端显示1-10:

"autoWidth": true,
            "processing": true,
            "serverSide": true,
            "ajax": {
                'type': 'POST',
                'url': 
                'dataSrc':function (json) {
                   

                    return json.data;
                },
                'complete': function (response) {
                   
                }
            },
            "columns": [
                {"data": "id"},
               {"data": "attribute", "name": "name",
                    "render": function (data, type, full, meta) {}
}
                    ---
                  ---

Consider the following snippet.考虑以下代码段。

"columns": [{
  "data": "id"
},
{
  "data": "attribute",
  "name": "name",
  "render": function(data, type, row, meta) {
    return (row[1] + row[2] + row[3]);
  },
  "targets": 4
}]

See More: https://datatables.net/reference/option/columns.render查看更多: https ://datatables.net/reference/option/columns.render

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM