Searching rendered column

Searching rendered column

agent_discoagent_disco Posts: 2Questions: 0Answers: 0

I have a table with price amounts represented in JSON as plain numbers but am using columns.render to format it as a price with a format like $5.25.

In my demo try searching for a dollar sign and see how nothing matches.

It seems possible this is somehow done using a custom render that keys on a type of filter but I couldn't wrap my head around it.

Any ideas?

Replies

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    The Data Renderers doc states this:

    The primary advantage of using a data renderer in DataTables is that you can modify the output data without modifying the original data.

    So the use of render: $.fn.dataTable.render.number(',', '.', 2, '$') is only affecting what is displayed.

    If you want the $ to be searchable then you will want to use Orthogonal Data so you can prefix the $ to the number for searching and display.

    You can use the same renderer just chain it with .display(data). For example:
    http://live.datatables.net/jeveqino/1/edit

    Kevin

  • agent_discoagent_disco Posts: 2Questions: 0Answers: 0

    Kevin, thanks for the update. This does work with the "$" now.

    However, if the data shows "$1,500" using orthogonal data is there a way I can still match if someone tries searching for "1500"? It's basically being able to search on two separate strings.

This discussion has been closed.