Providing alternative data to Search

Providing alternative data to Search

longpalongpa Posts: 3Questions: 1Answers: 0
edited September 2022 in Free community support

We have a table that contains a user's email address, their first name and last name and some date columns. The standard search works great for those.

I would like to provide a way of the user being searchable by their user id which is a GUID.

I know I could use the data-search attribute on the user name column e.g.

data-search="43b30438-e3c8-4e27-8b31-5fcc52e53a3b me@test.com"

However that makes that row and any other row findable with just the number "43" as that GUID starts with 43 or "52" because it has a 5 followed by an 2. That is clearly not what I want. How do I make the users searchable by their GUID as well as their username but in the case of the GUID only when it is the whole GUID being searched for?

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    DataTables doesn't provide a way of doing exactly what you describe I'm afraid. You'd need a custom plug-in to perform the search which would detect the GUID and alter how it performs the search based on that.

    Allan

  • brigosx71brigosx71 Posts: 1Questions: 0Answers: 0

    It is a bit late but I found this today searching for something different regarding the Search option of DataTable.

    In case you have upgraded your DataTable to 2.0 or higher you can apply a custom function as a parameter to the .search() method. The boolean result will exclude / include the desired rows accordingly.

    Below is the link:
    https://datatables.net/reference/api/search()

Sign In or Register to comment.