Replies: 11 comments 3 replies
-
with vuetify.VDataTable(headers=("headers",), items=("vegetables",)) as table:
with vuetify.Template(raw_attrs=['v-slot:item.calories="{ value }"']):
vuetify.VChip({{ value }}, color=("getColor(value)",)
print(table) |
Beta Was this translation helpful? Give feedback.
-
Your question is also covered in slide 8 of that page |
Beta Was this translation helpful? Give feedback.
-
Cheers, I'll test it out asap :) |
Beta Was this translation helpful? Give feedback.
-
Hi, Sorry to get back very late on this, but I have been side tracked on other things. I have tried the lines above but I cannot make them work. Instead, I am posting here what it is working for me:
The only missing bit is that I am not finding a good way to pass the actual value of the item to a function with some conditionals in it to return the right color. Cheers. |
Beta Was this translation helpful? Give feedback.
-
Do you mean this line here:
It does not work for me, I get the following error: "JS Error => ReferenceError: getColor is not defined", but the function is defined just above as:
Cheers |
Beta Was this translation helpful? Give feedback.
-
Indeed you need to come up with your implementation of |
Beta Was this translation helpful? Give feedback.
-
Hi Sebastien, yes exacly, I can undestand I need my own implementation, but for whatever reason the function I code in python is not hooked up correctly. Here a super easy re-edition of tableDyna.py tutorial:
|
Beta Was this translation helpful? Give feedback.
-
Sounds good,
Should I provide it though a a dedicate script to be appended in
state.trame__script or maybe shoud I declar it after ',' in the tuple like
color (getColor(value), ''' function bla bla''')?
Thanks
Il Gio 14 Mar 2024, 19:37 Sebastien Jourdain (Kitware) <
***@***.***> ha scritto:
… getColor needs to be in JavaScript not python.
—
Reply to this email directly, view it on GitHub
<#438 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL4ZV6VMEUVLPK4MTXOOXVLYYHU6VAVCNFSM6AAAAABC7NI4YKVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DOOJQGIYTS>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks, it works like a charm. I think last thing on this topic for me would be this: Is there a way to loop through every cell in the table to color every number? I might do a for with veutify.Template() for every column, but I guess this is really the average Joe solution! Anyhow, I am posting here the solution (the poor man one) to help out others:
Cheers |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing the full solution for the community. In case it was not obvious you can use python to loop on the colums where you want colors. for col_name in ["calories", "fat", "protein"]:
with vuetify.Template(raw_attrs=['v-slot:item.' + col_name + '="{ value }"']):
vuetify.VChip("{{ item." + col_name + "}}", color=(f"getColor(item.{col_name})",),) |
Beta Was this translation helpful? Give feedback.
-
Yes, That's exactly waht I was planning to do with python. I have seen some people around using v-for in veytify, but the more I can get with python the better is! |
Beta Was this translation helpful? Give feedback.
-
Hi Sebasiten,
I am moving on to tables right now and I managed to do some basic ones following your tutorials.
Q1)
Now, I would like to do some more fancy stuff and I am trying to reproduce some of the examples on veutify like:
https://vuetifyjs.com/en/components/data-tables/basics/#item-key-slot
Is that possible doing something like this in Trame? I haven't seen an example around yet for that .
Q2)
Is footer_props something mapped?
FYI:
Footer props are set using this syntax:
footer_props=[{'nextIcon': 'mdi-plus', 'prevIcon': 'mdi-minus', 'itemsPerPageOptions': [2, 4, 6, 8, 10]}]
Cheers
Beta Was this translation helpful? Give feedback.
All reactions