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

    HTML In V-Slot Not Rendering As HTML

    Framework
    3
    15
    1391
    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.
    • T
      tof06 last edited by

      Don’t use format option for that. I would rather render the html into the scoped slot:

      <q-table
         ...
       >
       <template v-slot:body-cell-landline="props">
        <q-td :props="props">
          <a v-if="props.row.landline" href="mailto:{{props.row.landline}}">{{props.row.landline}}</a>
          <template v-else>none</template>
        </q-td>
      </template>
      ...
      </q-table>
      

      Note that I used a template tag for the v-else, but you can use any other tag/component, for ex, a q-badge to make it look nicer.

      1 Reply Last reply Reply Quote 1
      • s.molinari
        s.molinari last edited by s.molinari

        You should put your html in the template slots (as tof06 just pointed out). Formatting is just for the content of the data. So, if you put HTML in there, you’ll only get it as a text output (as you are getting).

        You can also try a computed property instead of the method to create your thisPhone version of the phone number.

        Scott

        1 Reply Last reply Reply Quote 1
        • O
          omgwalt last edited by omgwalt

          @tof06 @s-molinari
          I tried that. Unfortunately, that gets me:

          Errors compiling template:

          href=“mailto:{{props.row.landline}}”: Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id=“val”>.

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            Like I said, probably need a computed property to build the href. You can do computed properties and add HTML. 😄

            If you put together a codesandbox or codepen, I’ll show you what I mean.

            Scott

            1 Reply Last reply Reply Quote 0
            • O
              omgwalt last edited by omgwalt

              @s-molinari
              I’d never set up a codepen before, so it took me a few tries. Here it is:
              https://codepen.io/vahost/pen/GRJLRaW?editors=1111

              1 Reply Last reply Reply Quote 0
              • s.molinari
                s.molinari last edited by

                Oh. I completely overlooked you are using grid-mode. Those slots won’t work in grid mode and this will now only work in grid mode. Hope it helps.

                https://codepen.io/smolinari/pen/bGdJBqX?editors=1010

                Scott

                1 Reply Last reply Reply Quote 2
                • O
                  omgwalt last edited by

                  @s-molinari Tell me more about that. Why won’t slots work in grid mode?

                  Thanks for the pen, by the way! I’ll study it next.

                  1 Reply Last reply Reply Quote 0
                  • s.molinari
                    s.molinari last edited by

                    Because in grid mode, those slots simply aren’t used. They are for the normal table mode only. So, if you want the formatting to happen in normal mode too, you’d need all of the slots set up for the output.

                    Scott

                    1 Reply Last reply Reply Quote 0
                    • O
                      omgwalt last edited by

                      @s-molinari Are you saying that there are other slots that ARE used in grid mode, or are you saying that no slots are ever used in grid mode? I’m still trying to understand what you’re saying.

                      1 Reply Last reply Reply Quote 0
                      • s.molinari
                        s.molinari last edited by

                        😁

                        In normal (non-grid) mode, all the cell, body, etc. slots are put to use, if you use them. If you switch to grid mode, they are ignored. The only slot used in grid mode is the item slot.

                        I hope that makes it clearer.

                        Scott

                        1 Reply Last reply Reply Quote 1
                        • O
                          omgwalt last edited by

                          @s-molinari Ah! Yes, that helps a lot. Thanks again!

                          1 Reply Last reply Reply Quote 0
                          • O
                            omgwalt last edited by omgwalt

                            @s-molinari I have a problem with your pen that I can’t resolve.

                            For the first and last names, the only way the search will find them is if I start with the first letter of the first name.

                            So typing the first letters of the last name fails to find the correct rows.

                            But with the other fields, I can enter any few letters, even in the middle of a word, and it will keep the rows that contain that substring regardless of whether the substring starts at the beginning of the value.

                            How can I change this?

                            1 Reply Last reply Reply Quote 0
                            • s.molinari
                              s.molinari last edited by

                              Updated.

                              https://codepen.io/smolinari/pen/bGdJBqX?editors=1010

                              You should show what you attempted in your own pen (could be a fork of mine). Maybe I could have just answered with a reply to lead you in the right direction. 😄

                              Scott

                              1 Reply Last reply Reply Quote 1
                              • O
                                omgwalt last edited by

                                @s-molinari Will do going forward. Thanks!

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