taipy icon indicating copy to clipboard operation
taipy copied to clipboard

Add formatting in tables using functions

Open chrisOnWheels opened this issue 2 years ago • 8 comments

Currently Taipy uses printf style formatting in tables

<|table|data={my_data}|columns={col_format}|...|>
col_format = {'Sales':'%.2f'}

This could be extended by allowing functions, like in <|selector|adapter={...}>

col_format={ "Sales": {"format_function": format_func}}

def format_func(data, column_name) -> list[str]:
    ... apply formatting ...
    return formatted_column_data

Such functions might even return images

Background:
I'd like to have floats formatted like 9.999,99 which seems not possible using pure printf style syntax in Taipy. Taipy doesn't support %'d to get locale aware thousands separator. AFAIK printf doesn't support thousands separators in floats.

chrisOnWheels avatar Aug 30 '23 08:08 chrisOnWheels

Thank you for your issue! It seems like a good feature! We will talk about it inside our R&D team

FlorianJacta avatar Aug 30 '23 08:08 FlorianJacta

Hey @FlorianJacta, is this feature required, may I give it a try to add this?

yaten2302 avatar Jun 28 '24 16:06 yaten2302

@FabienLelaquais @FredLL-Avaiga Could this issue be assigned?

FlorianJacta avatar Jul 01 '24 07:07 FlorianJacta

It certainly can. The thing is, it is far more complicated than it looks since the conversion to string has to be performed on the server side, which is going to be a problem. Especially for the edition part. But hey, let's move forward yes.

FabienLelaquais avatar Jul 01 '24 07:07 FabienLelaquais

Hey @FabienLelaquais @FlorianJacta , I've a doubt in this, like instead of letting the user provide the format function, can we provide our own format functions? like, we can have some functions which renders a specific number of rows that the user requires or something like that?

If the user passes the format function, then will it be possible to implement that?

yaten2302 avatar Jul 01 '24 19:07 yaten2302

I am not sure I understand your issue @yaten2302. We want a function that converts all values of the rows of a column into other values that will be the ones displayed.

FlorianJacta avatar Jul 10 '24 07:07 FlorianJacta

@FlorianJacta actually, I'm not completely able to understand this? Could you please explain this once again - "We want a function that converts all values of the rows of a column into other values that will be the ones displayed."?

yaten2302 avatar Jul 12 '24 16:07 yaten2302

We want to use a user function to format column values. Just, like the example written in the issue.

Maybe you already understand it this way, and I am just overcomplicating it.

FlorianJacta avatar Jul 15 '24 08:07 FlorianJacta