I have a table I am showing in perspective and my time stamp is displaying as a number instead of a date. when I execute the name query is shows as a date. the column is listed as date format and showing the date in the dataset editor. but for some reason it is displaying as a number in the table.
configure the table columns in the columns
property:
make sure you set up the field
property, assign it the column name. This should fix it.
Hi @Glen_Bennett,
under the table properties you can add columns definitions
in field set the name of the column you want to adapt
render set to date
set the correct date format.
You will need to do this for each column you want to visualize in your table
Regards
That fixed it. Thanks!
to add onto that question, when the field is editable it pops up as a number. Any suggestions?
I solved this problem by holding the data in a custom property and creating a binding from that property to <Table>.props.data
, with a script transform to use the system.dataset.formatDates
function. I then store any edits to the custom property (or directly to a database, as need be), which refreshes the props.data
binding automatically.
You can use the function directly in the same binding that gets the data if reading from an external data source, but it will change the column to String, which will accept any value and lose the automatic translation that Date columns have.
Welcome to the forum, Ray.
That's the problem with your solution.
The advice is to always keep dates as date types until the point of display to a human. That way you can still perform calculations, database inserts, accommodate timezones, etc.
Arnoud's solution Perspective table date showing as number - #3 by Arnaud_Declerck is the correct one. Add the database column name to the column's field
property, render as date and then the formatting will all work.
Agreed, good callout. If you don't need the ease of editing a human-readable date in place, using the render property on the column maintains the greatest amount of functionality. The specific problem my solution solves, and that which Arnaud's solution leaves unsolved, is that changing the render property only solves the formatting for displaying while not editing and for writing back to the dataset.
This is enough for most cases, but if editing the cell directly (as opposed to through an embedded view or other UI component) the date displayed when editing is the millisecond unix timestamp.
The reason for having a background property driving as the "actual" dataset is to get the formatting a similar level of distance away from the data as the render property gets natively.