Individual column searching (select inputs) not showing apostrophe

Individual column searching (select inputs) not showing apostrophe

tgatarictgataric Posts: 4Questions: 2Answers: 0

Hi, I have data in one column in datatable like this:

Sample Test
Sample"
Sample Test3
Sample"
Sample"

On that column I inserted individual column searching (select) and in select I have values like on picture I'm sending.

When I click on Sample Test it filters result. But Sample " doesn't filter anything. Filters with apostrophe don't work.

Is there solution to filter it?

Answers

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

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • tgatarictgataric Posts: 4Questions: 2Answers: 0

    Test is here http://live.datatables.net/wivesire/1/edit?html,css,js,console,output

    I entered data Sample 3" and Sample 4" to table and it doesn't filter on select.

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,922

    A little debugging helps to find the issue. I put a console.log statement in the change event to see what values are being searched. In the console it shows the " is removed from the select value. This is due to how you are building the options:
    select.append( '<option value="'+d+'">'+d+'</option>' )

    You are placing " around the value so in the case of " it looks like this <option value="Sample 3""> which is incorrect. Basically you need to swap the ' and " in the statement. Take a look at this example:
    http://live.datatables.net/wivesire/2/edit

    It uses the original statement. But you can comment that out and use the updated statement.

    Kevin

This discussion has been closed.