i have alternative words and i want the search know alternatives

i have alternative words and i want the search know alternatives

ASHKARdatatablesASHKARdatatables Posts: 18Questions: 5Answers: 0

hi every one ,

i face a problem, that there is alternatives words such as : united states = usa = america = united states of america , hematology = cbc

so when the user try to search for cbc the message show : No matching records found

if the user search for (united states) or (usa) or (america) or (united states of america) , the united states rows will show

the code :

jsfiddle.net/BakBaka7a/7cabjt3m/4/

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954
    Answer ✓

    One option might be to use Orthogonal data. In the columns.render function for filter look up the column data to get a space separated list of alternatives. For example:
    http://jsfiddle.net/o6a0zyrk/

    Kevin

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    Thinking about it my example won't work correctly. For example if you type "states" it will match the United States cells. Let me think about it or maybe someone else will respond with a better solution.

    Kevin

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Individual column filters, with select inputs:

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

    Otherwise this is beyond the scope of DataTables.

  • ASHKARdatatablesASHKARdatatables Posts: 18Questions: 5Answers: 0
    edited June 2023

    it worked fine Kevin, thanks :smiley:

    just make some changes , i added the same word again in alternatives

    ex : 'Hematology': 'Hematology cbc',
    'United States': 'usa america united states of america',
    and i changed the target to be targets: '_all',

    this is the code

    https://jsfiddle.net/BakBaka7a/zcx2eLdo/5/

  • kthorngrenkthorngren Posts: 21,337Questions: 26Answers: 4,954

    Good glad it works for you. Using targets: '_all' is a good choice.

    Kevin

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    I wonder if the fuzzy search might be of interest as well. It won't help with something was different as USA and "United States of America", but it will help for closer words.

    Allan

  • ASHKARdatatablesASHKARdatatables Posts: 18Questions: 5Answers: 0

    hi Allan,
    unfortionitly, not even closer words

Sign In or Register to comment.