I have a column which has suffix m in it. Any way to remove m and process data for sorting?
I have a column which has suffix m in it. Any way to remove m and process data for sorting?
techaddict009
Posts: 7Questions: 1Answers: 0
Is pre-processing of column available? So that m can be removed before processing. (Not from display just for sorting purpose).
This discussion has been closed.
Answers
Sure - use
columns.render
.Allan
Seriously I am not getting how to use it. Seems like there is need for proper examples. I just checked this example : http://www.datatables.net/examples/advanced_init/column_render.html
I couldnt get how to use it my case!
Assuming I understand correctly, then:
i.e strip the last character off the data. (edit When I wrote this originally I striped a prefix, rather than postfix).
If that isn't want you meant, please clarify with a link to a test case showing the issue.
Allan
Yes you have understood it correctly.
But One query how to apply this only to specific column say column no 11 (Starting the count from 0).
Table looks similar to this: http://datatables.net/examples/basic_init/zero_configuration.html
I am using zero configuration. Want to apply the rendering thing to column 11 which has m in the end and rest normal integer. ex: 1m, 2m, 4m, etc. Sorting to be done only on 1, 2, 4,etc.
Thanks in advance. And for quick responses.
Use the
columnDefs.targets
option to apply it to a specific column, or set of columns.Allan
Sorry I was using older version of data tables which was causing the issue.
So now my issue is. for sorting is done the way i want but m is getting removed from display. I just want m to be removed from sorting logic not from the front end.
Found the fix. Need to use if condition on type=="sort"
Thanks @Allan for all your support.
Hope someone writes a simple guide for beginners like me.