Forum Discussion

micha80's avatar
micha80
Expert
10 years ago

Filtering for first char in LiQL

Hi all,

 

I have a custom component which builds a list of messages with a filter above them. The filter is just a list of alphabetical ordered chars. When the user clicks on a char the list is filtered and all messages where the subject starts with the selected char will be shown. There is also an pagination. Actually I am not so happy with the solution I build and wanted to rebuild this with LiQL much more efficiently. But I don't know how to search for a list of messages and use a condition which filters on the basis of the first char. 

 

Example: User clicks on char "A" and all messages where the subject starts with an "A" should be loaded.

 

Is this possible with LiQL?

 

Regards,

Michael

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    micha80

     

    If I had to do it, I would:

     

    1- use JQuery to get what the user is entering in the box

    2- build the LiQL query, using the WHERE close, and adding the string you've capture in 1

    3- use an AJAX call so the page doesn't reload ; and displays results as soon as it arrives

     

    Sorry for not providing the exact code.

    • micha80's avatar
      micha80
      Expert

      Hi OlivierS,

       

      thanks for your answer. Could you please tell me what where condition I should use to check if the first char of a message subject is an "A"? I havn't found anything. In SQL I have something like the "Like" syntax but there is nothing like this in LiQL. Am I correct?

       

       

      Regards,

      Michael

      • OlivierS's avatar
        OlivierS
        Lithium Alumni (Retired)

        micha80 

         

        Sorry. you're correct. It looks like the WHERE clause doesn't have a 'like' keyword (maybe for performance optimization).

         

        You could use 'IN' or 'MATCHES' keywords, but with only one letter, it might return too much. Although, it won't only return messages starting with 'A' (or the letter you specify) but all messages containing that letter ... So you will have to apply some RegEx once the message is returned ... Try that on stage first to evaluate performance impact.

         

        Or wait for other people to respond as my knowledge on API / LiQL / JS is limited!