How to: 2 values in one column, count totals only by one of the values

How to: 2 values in one column, count totals only by one of the values

codrinhcodrinh Posts: 3Questions: 1Answers: 0

As per below image, I added a percentage difference in the column.
HTML example below, where "Value" is the value that I want to be counted in the footer at totals.
<td>Value<span class="float: right">-54 %</span></td>
When the 2nd value is added the totals are no longer generated.

Please advise if this can be achieved, thank you.

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598
    Answer ✓

    Hi @codrinh ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • codrinhcodrinh Posts: 3Questions: 1Answers: 0

    Hi Colin,

    Thank you for the reply.

    I've replicated the scenario here:

    http://live.datatables.net/wayoxexa/1/edit?js,output

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921
    Answer ✓

    You will need to parse the string that makes up the column data, for example: "0<span class="float: right">-100 %</span>", to extract the value you want.
    The easiest way to see this is with a console.log statement. I added one to your example:
    http://live.datatables.net/zamihama/1/edit

    If you look at the footerCallback example it shows that all the data is converted to an integer. For the specific column that contains the percentage you will need to follow the same logic but the function you call will extract the portion of the string you want.

    Kevin

  • codrinhcodrinh Posts: 3Questions: 1Answers: 0

    @kthorngren thank you for the assistance, I'm in a different world when it comes to JS :)

This discussion has been closed.