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

    [1.0.5] QTable hide some rows based on criteria

    Help
    2
    8
    1151
    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.
    • P
      pavarine last edited by

      I’m using Qtable with some custom cells via template slots that are working fine, such as:

      <!-- Agent icon column slot -->
      	<template v-slot:body-cell-id="cellProps">
      	  <q-td>
      	    <q-btn round
      		unelevated
      		size="xs"
      		:color="agent_table_icon_color(cellProps.row)"
      		:icon="agent_table_icon(cellProps.row)">
      	     </q-btn>
      	   </q-td>
              </template>
      
      	<!-- Time column slot -->
      	  <template v-slot:body-cell-time="cellProps">
      	    <q-td>
      		{{calc_time(cellProps.row.last_state_change_time)}}
      	  </q-td>
      	</template>
      

      And now I want to dynamically hide/unhide some rows of the table based on a criteria (status) that is present in the row… I thought I could do this using the “body” or “body-cell” slots of QTable, but when I do this I lose all the custom I made in body-cell-id and body-cell-time. Is that a way that I can achiev what I trying to do in some way? Thank You

      metalsadman 2 Replies Last reply Reply Quote 0
      • metalsadman
        metalsadman @pavarine last edited by

        @pavarine use v-if https://vuejs.org/v2/guide/#Conditionals-and-Loops.

        1 Reply Last reply Reply Quote 0
        • P
          pavarine last edited by

          @metalsadman thanks for your reply. Where would I use the conditional? I’ve not access to “each row” …

          metalsadman 1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman @pavarine last edited by

            @pavarine in your template slots possibly.

            P 1 Reply Last reply Reply Quote 0
            • P
              pavarine @metalsadman last edited by

              @metalsadman Am I supose to do something like this?

              <template #body-cell="bodyProps" v-if="bodyProps.row.status === 'Logged Out'" >
              						
              </template>
              

              On rendering this I’m getting:

              TypeError: Cannot read property ‘row’ of undefined

              1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman @pavarine last edited by

                @pavarine in the inner element https://codepen.io/metalsadman/pen/pMozeQ?editors=1011

                P 1 Reply Last reply Reply Quote 0
                • P
                  pavarine @metalsadman last edited by

                  @metalsadman Appreciate your help, but if I put a conditional on the “body-cell” slot inner element, it keeps overwriting the “body-cell-time” and “body-cell-id” slots when the conditional passes:

                  <template #body-cell="bodyProps">
                  	<q-td :props="bodyProps" v-if="bodyProps.row.status === 'Logged Out'">
                  	</q-td>
                  </template>
                  

                  If row.status === ‘Logged Out’ then the empty <q-td> is rendered (no row at all, wanted effect) but when row.status !== ‘Logged Out’ then nothings got rendered cause the body-cell slot overlaps the other body-cell-* slots.

                  1 Reply Last reply Reply Quote 0
                  • P
                    pavarine last edited by

                    Nevermind, I was able to achiv this, just in a manner slightly different then I was previous thinking. Thank you

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