Having difficulty with column summarizing
Having difficulty with column summarizing
Link to test case:
**Debugger code:
// column which is being rendered:
{ "data": "null",
render: function ( data, type, row ) {
return (sumCols(row.price_sold) * sumCols(row.qty_sold)).toFixed(2);
}
// column summarizing function which works fine on other coulmns with ordunary data, but fails with this rendered column
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
var Total7 = api
.column( 7, {page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 7 ).footer() ).html((Total7).toFixed(2));
**:
Error messages shown: DataTables warning: table id=example2 - Requested unknown parameter 'null' for row 0, column 7:
**Hi there, currently I am working on one project, which requires summarizing on several columns. Everything is fine with all columns except one, which throughs error every time when I reload page. The thing is, this very column's data is being rendered by multiplying two other column values to each other and that is why "intVal" function can not summarize the column values. Can any one help me with this please? **:
Answers
Since you are using
columns.render
for these columns you will need to usecells().render()
to access the data. Take a look at this example from this thread to see how.Kevin
Thank you very much Kevin