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

    What is the best way to handle q-table props??

    Help
    4
    10
    3317
    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.
    • L
      leonardoebert last edited by

      I’m using q-table on a project and i’ve been facing a situation that let me curious.
      I am passing this "@click.native=“rowClick(props)” on q-table tag and “<q-tr slot=“body” slot-scope=“props” @click=“rowClick(props)” >” inside the q-table.
      But it is asking to declare props on data (), but if a declare it, when i click on the row and put a console.log() on the function it returns to me empty, and if i don’t declare it returns me undefined.

      What i want to know is the exact way to use the props on q-table.

      1 Reply Last reply Reply Quote 0
      • Hawkeye64
        Hawkeye64 last edited by Hawkeye64

        You’re missing :props="props"
        Here’s an example of mine:

        <q-tr :id="props.row.id" slot="body" slot-scope="props" :props="props" @click.native.stop="rowClick(props.row)" @dblclick.native.stop="rowDoubleClick(props.row)" class="cursor-pointer" @mouseover.native="hoverMouseOver(props.row)" @mouseout.native="hoverMouseOut(props.row)" :style="selectedStyleObject(props.row)">
        
        L 1 Reply Last reply Reply Quote 2
        • L
          leonardoebert @Hawkeye64 last edited by

          Hi @hawkeye64, are you declarating props on the data()???

          0_1537581499493_Captura de tela de 2018-09-21 22-57-34.png

          When i declare it this way it returns to me a empty string, and if i don’t declare it returns undefined. If possible you cloud show me a complete example??

          Appreciate your help…

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

            Here is a working example taken from the source code of the play app.

            https://jsfiddle.net/49n8cLks/

            Scott

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

              props by the way, is the property (prop) built into the q-th, q-tr and q-td components. The v-bind method of :props is what is allowing those child components, used to fill slots, to get the data. You’ll notice in the example above, props is nowhere to be seen in the JS data() function.

              Scott

              1 Reply Last reply Reply Quote 1
              • Hawkeye64
                Hawkeye64 last edited by Hawkeye64

                @leonardoebert Exactly what he ( @s-molinari ) said! 🙂

                1 Reply Last reply Reply Quote 0
                • L
                  leonardoebert last edited by

                  @Hawkeye64 , @s-molinari , the example works for me. It was a silly mistake that I did not see what was wrong. I really aprecciate the help from both of you…

                  1 Reply Last reply Reply Quote 2
                  • Hawkeye64
                    Hawkeye64 last edited by

                    Glad to have helped!

                    1 Reply Last reply Reply Quote 1
                    • M
                      MusicForMellons last edited by MusicForMellons

                      @Hawkeye64 @s-molinari Uh…, is this still relevant under quasar v1 ?

                      1 Reply Last reply Reply Quote 0
                      • Hawkeye64
                        Hawkeye64 last edited by

                        The scoped slot passes out props from q-table, which needs to be passed into q-tr.

                        Name
                        props
                        
                        Description
                        QTable's row scoped slot property
                        
                        Example
                        :props="props"
                        
                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post