Data tables search render columns

I am using data tables and have joined some columns using the render feature: https://datatables.net/examples/advanced_init/column_render.html

However when I use the data tables search I only want to search the content of the original column and not the other text which has been joined using the render.

I thought I could use this https://datatables.net/examples/advanced_init/html5-data-attributes.html

However it seems to search the data-search attribute and the column contents.

How can I get the search to only search in the data-search attribute?
petewinterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Have you read through this DataTables API

https://datatables.net/examples/api/multi_filter.html

It shows a sample where you can attach a text box to each column and have the search text entered in that text box apply only to that column using the column().search() api

https://datatables.net/reference/api/column%28%29.search%28%29

You might also find this discussion useful which talks about the bSearchable (https://legacy.datatables.net/ref#bSearchable) option
petewinterAuthor Commented:
Thanks for the reply Julian.

I have tried the multi filter as you suggested however the search still picks up the text joined from the other columns.

See my example...

http://www.cmyuk.com/admin/orderpad/datatables.php

In the rows you will notice there is a second line. For example "Colour: CLEAR, Capacity: 1000". This information has been joined using the column render feature (https://datatables.net/examples/advanced_init/column_render.html). I do not want this text to be searchable. I only want to search the original column contents.

Hope that makes sense and any idea how to do this?
Julian HansenCommented:
It makes sense in terms of what you want to do but not sure you are going to find a solution to this without customising the search function and that is going to be tricky.

You want the search to figure out that from (its perspective)

text text text text text

You don't want it to search using the last two text's - it has no idea of syntax so realistically the above is all it sees. It requires human specific knowledge (in this case yours because until you explained your intent - no other human would - from the text displayed - be able to discern what should be included in the sort and what should not.

You want to be looking at custom filtering https://datatables.net/examples/plug-ins/range_filtering.html and even then you might need to think about this. If you include html tags in your search requirements you might get results where matches target attributes and if you exclude html tags in search then you loose the ability to delimit the text you want to exclude.

Personally, I have not come across this before so don't have a ready solution for you but you might want to rethink what you are trying to do and build your functionality around a custom filter that specifically excludes the text you don't want in the search.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
petewinterAuthor Commented:
Thanks for you advice. I agree I probably need to give an alternative filtering option.
Julian HansenCommented:
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.