No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    q-table highlight filtered value

    Help
    filter highlight hits q-table
    3
    5
    446
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      erhard last edited by

      Hello, all

      I use the q-table in grid style. Has anybody an idea how I can highlight the filtered text ?

      I have a lot of textfields One is for example
      “bla bla target bla bla”. The filter filters the record with “target” But now because there is a lot of text it would be great if there is an idea how to make the word target e.g. blue.
      best regards
      erhard

      1 Reply Last reply Reply Quote 0
      • N
        nededa last edited by nededa

        If I understood you correctly you could just wrap it in span element by using replace and then use v-html to render html. Something like this:

        <q-td
            key="calories" 
            :props="props"
            v-html="props.item.calories.replace(searchValue, `<span style='color:yellow'>${searchValue}</span>`"
        >
        </q-td>
        
        E 1 Reply Last reply Reply Quote 1
        • E
          erhard @nededa last edited by

          @nededa Thanks for Your reply. Yes this would work if you have data where a column is settled with one item like calories and a number. But I have a text like a disceiption of an item = prosa text in large textfields. Q-table works great to find single words in that text and filters properly. But when there is a large text the user expects to see the hits somehow.

          N X 2 Replies Last reply Reply Quote 0
          • N
            nededa @erhard last edited by

            @erhard you mean you want to highlight input text? You could just hide text and use default slot to show div on top of input also disable pointer events for div overlay. It is a bit hacky but either this or you’ll have to replace your inputs with div+contenteditable.

              <q-input v-model="text" label="Standard">
                <template v-slot:default>
                  <div class="relative">
                    <div 
                         class="absolute text-black" 
                         style="left:0;top:25px;pointer-events:none"
                         v-html="text.replace(search, `<span class='text-red'>${search}</span>`)"
                    ></div>
                  </div>
                </template>
              </q-input>
              
              <style>
              
                input {
              
                  color: white !important
              
                }
              
              </style>
            1 Reply Last reply Reply Quote 0
            • X
              xdesai @erhard last edited by

              @erhard You could use the “item” scoped slot to create a custom template to output your data e.g. in a card, then use v-html and string replacement:

              https://codepen.io/xariusdesai/pen/XWNBLNZ

              1 Reply Last reply Reply Quote 1
              • First post
                Last post