Shortest match first

Shortest match first

spidogrspidogr Posts: 23Questions: 9Answers: 0

For example there could be cells like these:

this is a big row
this is a small row
this is a another row
another row
small row
row

in which case the preferred first match when searching “row” should be the cell which contains just that.

Replies

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

    The search and the ordering are entirely independent, but you could create a custom ordering plugin (see here) that orders a column by the length of its contents.

    Colin

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    edited June 2021

    If you want to match a specific word then you will want to use regex searching. See this example:
    https://datatables.net/examples/api/regex.html

    Kevin

  • spidogrspidogr Posts: 23Questions: 9Answers: 0

    I am interested in how the results are displayed after a Search.

    I checked the regex, but I cannot understand how I could make it match by default the full cell content and/or the shortest cell content (and the rest of the matches further down on the same logic). For example I tried ^developer to match Developer **only but not **Javascript Developer and I got nothing.

    I see that in the roadmap v1.11 is meant to address Search weaknesses.

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Did you check regex and uncheck smart search? Like this:

    Kevin

  • spidogrspidogr Posts: 23Questions: 9Answers: 0

    I was doing it on Global search. It only works for Position search.

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

    Yeah, there are a few threads on that, such as this one here - see Allan's comment at the end. I agree it's non-intuitive, it caught me out too!

    Colin

Sign In or Register to comment.