[1.0.5] QTable hide some rows based on criteria
-
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 thanks for your reply. Where would I use the conditional? I’ve not access to “each row” …
-
@pavarine in your template slots possibly.
-
@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
-
@pavarine in the inner element https://codepen.io/metalsadman/pen/pMozeQ?editors=1011
-
@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.
-
Nevermind, I was able to achiv this, just in a manner slightly different then I was previous thinking. Thank you