appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.62k stars 3.73k forks source link

[Feature]-[500]:Allow devs to format numbers in table #6942

Open areyabhishek opened 3 years ago

areyabhishek commented 3 years ago

Summary

Numbers need to be shown in formats: 10,00,000 or 1,000,000 or 1,000,000.00, etc. We should show a condition that shows these options in the property pane.

User can use toLocalestring to achieve this in JS

somangshu commented 3 years ago

@areyabhishek are you talking about the table widget or the input widget.

Also, would something like a toggle called as internationalised format work?

@Nikhil-Nandagopal can you think of a better terminology here?

Nikhil-Nandagopal commented 3 years ago

I think just the number format is good. This needs to be a dropdown where a user can select the format (Check Google Sheets format option). This should only be in places where the data type is known i.e Input & Table. Users should use a JS lib for places like text

somangshu commented 3 years ago

@Nikhil-Nandagopal I didn't quiet get it!

Nikhil-Nandagopal commented 3 years ago

It's valid for any numerical type including currently. See the screenshots

Screenshot 2021-09-08 at 4 14 35 PM

from google sheets

Screenshot 2021-09-08 at 4 14 18 PM
somangshu commented 3 years ago

Oops, I was checking the appsmith google integration 🙈

Got it now, thanks.

vicky-primathon commented 3 years ago
vicky-primathon commented 3 years ago

Below formatting options will be supported

  1. 1,122,222.21 / 10,00,000 (Localised formats)
  2. 123.4 (precision)
  3. 44.22% (percentage format)
dilippitchika commented 2 years ago

We can follow something similar to the property exposed in date fields, which is display date format.

Reach - Users configuring the table's col as number type Impact - Low Effort - Assuming 1 sprint for dev+design+QA

Stats

Stat Values
Reach 500
Effort (months) 0.5
somangshu commented 2 years ago

@dilippitchika I think this should also be a part of the input widget! Under the type number these formatting options are valid for the user

dilippitchika commented 2 years ago

@somangshu i was only considering this for display purpose and not the editing purpose yet. That is the reason i removed the input widget.

If we were to add it there as well, i believe the issue should be updated, because the impact is for app-viewer will be higher because they can edit the values.

somangshu commented 2 years ago

@dilippitchika in that case, I also want to think about how this will pan out for table widget inline edit, Will be persist the formating or remove it before the editing starts.

another point is that this can we the output also, like {{input1.text}} gives out the formatted label required many times by the DB

Nikhil-Nandagopal commented 2 years ago

I think it should work exactly like google sheets or our date picker. The underlying format is a number and you input it as a number in edit mode but there is presentation logic to add commas

bobbintb commented 2 years ago

I came across a need for this recently. I have file sizes in a column that are difficult to read in the default format (bytes). I have a JS function to make it more human readable but that makes it impossible to sort. I even tried changing it to a date type and using the custom JS but that did not work. I think something similar to the date type would work well, and give formatting option like Google Sheets.

Tooluloope commented 2 years ago

@bobbintb are you formatting the column after it's been rendered on the table, or are you formatting the data before it gets to the table?

bobbintb commented 2 years ago

@bobbintb are you formatting the column after it's been rendered on the table, or are you formatting the data before it gets to the table?

I'm formatting before it gets to the table via the computed value in the widget. I'm not sure how I would do it otherwise.

Tooluloope commented 2 years ago

You can format the data just before it gets to the table, not the column.

bobbintb commented 2 years ago

You can format the data just before it gets to the table, not the column.

I'm not quite following. The table widget displays data from a MongoDB query. If I leave the data I can sort it but it's difficult to read. If I format it I can read it better (ex 93.05 MB instead of 97569381) but it breaks sorting because it is no longer a number. Are you saying I can format it and keep sorting functionality or would this require a new feature?

Tooluloope commented 2 years ago

@bobbintb Do let me know if this settles your use case.

https://user-images.githubusercontent.com/31691737/202294179-20ad0afb-99c8-498e-bb12-6f92acb2c501.mov

bobbintb commented 2 years ago

It doesn't unfortunately. It still transforms the data. The sort works with the specific test numbers you've chosen but I think it will break like mine did with more varied examples (KB, bytes, GB, etc).

Tooluloope commented 2 years ago

Oh got it. This won't work with varying bytes unit

Tooluloope commented 2 years ago

@dilippitchika @sbalaji1192, is there another way to unblock him?

sbalaji1192 commented 2 years ago

@Tooluloope @dilippitchika I don't think it is possible without a property to format numbers while rendering the cells like the date output format property.