Render Human Readable numbers

Render Human Readable numbers

tux57tux57 Posts: 20Questions: 5Answers: 0

Hello
Is it possible to have a number rendering for a human number format with the render function of datatable ?

example of human number format

100 000 ---------> 100k
10 000 000 -----> 10MM
... ect

Thank you very much

Franck.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    This came up recently in another thread. There isn't an out of the box solution currently, but it is quite possible.

    Allan

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @tux57 ,

    This thread here will help - it was asked recently, and the conclusion was to use numeral.js - see @kthorngren 's second comment.

    Cheers,

    Colin

  • tux57tux57 Posts: 20Questions: 5Answers: 0

    it's perfect !
    Thank you very much :)

    Best regards,
    Franck

  • tux57tux57 Posts: 20Questions: 5Answers: 0

    I come back to you the solution does not correspond to my request.


    https://datatables.net/forums/discussion/comment/134713/#Comment_134713

    http://live.datatables.net/gepudopi/1/edit

    This solution does not use human readable rendering directly in the array but in the footer. (the sorting does not work in this example)

    How can I merge the array rendering engine with the numeral.js function ?

    Thank you in advance

    Best regards,
    Franck

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi Franck,

    You would insert the numeral conversion (something like numeral(pageTotal).format('0.0a');) into the columns.render function,

    Cheers,

    Colin

  • tux57tux57 Posts: 20Questions: 5Answers: 0
    edited July 2018

    Thank you for your patience but I still can not...

    Can you help me directly in my next JS file?

    http://live.datatables.net/vananuwo/1/edit

    I would like to apply the format on the "price" column with the '0 a' numeral format.

    Best regards,
    Franck

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Yes, we'd be happy to create a working example for you. This is something that would be covered under the support options.

    Allan

  • tux57tux57 Posts: 20Questions: 5Answers: 0

    It's an amateur project, sorry i do not have the money for that.

This discussion has been closed.