-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
computed_field properties not showing in tables #320
Comments
I believe the main problem is here at the FastUI/src/python-fastui/fastui/components/tables.py Lines 46 to 57 in 97c4f07
Computed fields are accessible by from pydantic import BaseModel, computed_field
class Rectangle(BaseModel):
width: int
length: int
@computed_field
@property
def area(self) -> int:
return self.width * self.length
data = Rectangle(width=3, length=4)
data.model_fields.items() # Model Fields
data.model_computed_fields.items() # Computed Fields |
I'll work on this tomorrow and try to come up with a proper solution 🤓. |
@hasansezertasan thank you for the good insights and for looking into this enhancement! |
You're welcome, I'm happy to be able to work on this issue 🤓. I'd like to have your review if you got time to spare. #321 |
I have a model with some computed_fields and they do not show up automatically when I try to render them in a table, unless I explicitly define the
columns
of the table (and reference the field by name with aDisplayLookup
).The problem/inconvenience with this, is that now I have to specify every column with a DisplayLookup, just to include the one column that is a computed property. This makes my code less DRY and harder to maintain.
it would be nice if the table logic would find these computed properties and include them when the columns/fields are discovered.
The text was updated successfully, but these errors were encountered: