Column sum by column name
Column sum by column name
efremov
Posts: 1Questions: 1Answers: 0
I using this Sum plugin (https://datatables.net/plug-ins/api/sum()
Can I calculate sum based on COLUMN NAME instead of column index??
var api = this.api();
$( api.table().footer() ).html(
api.column( 4, {page:'current'} ).data().sum()
);
This discussion has been closed.
Answers
Yes!
Please take a look at this:
https://datatables.net/reference/api/column()
and this:
https://datatables.net/reference/type/column-selector
and maybe this as well:
https://datatables.net/reference/type/selector-modifier
Hi @efremov ,
Yep, that's just the
column-selector
, see this link here on how to specified named columns.Cheers,
Colin
Hi! It doesnt works. Look at my code, please. I use this function in drawCallback
var api = this.api(), data;
api.column('fraht_nal:name', {filter: 'applied'}).data()
returns undefinedHi @vivalaz ,
Yep, that's definitely correct, see the example here. Note,
filter
is only for backward compatibility,search
should be used now instead.If you're isn't working, I'd say double-check the column name. We're happy to take a look if you can provide a live example like mine above.
Cheers,
Colin
I had an array of columns like a:
I added name property like that:
And its works.
Special thanks for search note