[Help Needed] Is it possible to introduce a custom format for numeric cells Or How to sort text by value?

Hi There

I have one question about the number formatting of numeric cells.

We need to enable the sorting on columns. And the json data we received from server has the raw value as well as the formatted text for each cell { text: $1,234, raw: 1234 }, WITHOUT the number formatting patterns.(like $0,000). The reason is a bit complex, in our table each cell’s formatting is decided by several layers, to resolve the final used formatting patten requires heavy calculation, so we put it at server side.

So I am wondering how can I achieve this:
I have the formatted text already, so actually I do not need the HOT formatting capability. I want HOT to display each cell the way I told it to.
But meantime, I have to pass the data as numeric, because if I pass it as text, the sorting goes alphabetically, not numerically.

To add more informaiton, I looked into our requirements, I find that it is even more complex, for certain cells, we need to diaply them as symbols like:

For example: “when profit is increased by 20%, then display it as a upper arrow”
So in one column we have formatted numbers as well as symbols or texts
In such a case, can we still define this column as ‘numberic’? And if yes, which numeric formatted pattern should I use to get the effect done (some are $123, some are :arrow_upper_right: some are ‘abc’)

If we need to define this column as ‘text’, is there a way to get it sort by the numeric data behind the displayed text/symbol?

Hi again @semix1 :slight_smile:

Have you tried custom renderers? Here’s a simple example with yen http://jsfiddle.net/c6yr2onw/ and here’s a arrow symbol (U+2197) http://jsfiddle.net/1nhqkwsj/
Let me know if that’s not enough or you need something different.

Hi @aleksandra_budnik
Thanks for the reply, again.

Late night in Asia now, will definitely try your suggestion tomorrow.

Thanks
Semix.

1 Like

Hey @aleksandra_budnik

I tried your approach, and it works well.
There is one note to make, to get the correct row, col index before sorting, you need to get the information from cellProperties parameter of the renderer.
Something like this:

Really save my day, thanks again for the help!

Thanks
Semix

I’m happy that I could help @semix1

I believe that we can close this issue now as the case is solved.

1 Like