Skip to content

datetime formatting with natural sorting in the table component #895

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

Open
vks2 opened this issue Apr 25, 2025 · 4 comments
Open

datetime formatting with natural sorting in the table component #895

vks2 opened this issue Apr 25, 2025 · 4 comments

Comments

@vks2
Copy link

vks2 commented Apr 25, 2025

Hello, just some typical and simple questions

  1. If i want to render datetime value coming from SQL query in table component, do i need to write handlebars?
  2. If i want to colorize a row if the value coming from sql is true or false (bool field) I also need to make a handlebars?
    3.sadly that pagination = true in table component is not yet developed, it's a basic function in all similar libs

thanks much for your work

@lovasoa
Copy link
Collaborator

lovasoa commented Apr 28, 2025

Hi !

If i want to render datetime value coming from SQL query in table component, do i need to write handlebars?

No you don't. Are you having issues with rendering datetimes ? Can you tell us more about the issue you are having ? What database are you using, what does your table schema look like, what query are you using ?

If i want to colorize a row if the value coming from sql is true or false (bool field) I also need to make a handlebars?

No, you can use a case expression.

For instance

select 'list' as component;

select 
  title,
  case when has_errors then 'red' else 'blue' end as color
from orders;

3.sadly that pagination = true in table component is not yet developed, it's a basic function in all similar libs

Pagination is hard to implement in a way that is both

  • generic (allowing the developer to use it with any query they want)
  • and efficient (not downloading the entire result set at once on the client)

It is definitely possible, though. Contributions welcome !

@vks2
Copy link
Author

vks2 commented Apr 28, 2025

yes, i'm backed by a postgres tables. i need to keep datetime format (to filter properly) but to be able to show custom date formats at a table. alsoo i need to colorize rows by an easy rule, if a col is bool true the row is green. is it easely doable?
thanks much, for a half of a year you did a tremendous work
Best

@vks2
Copy link
Author

vks2 commented Apr 28, 2025

of course every dev is dreaming about opensource contribute to a high stared project. but we also have severe time constraints. so hopefully anyday our dreams will com true

@lovasoa
Copy link
Collaborator

lovasoa commented Apr 28, 2025

Oh, I see, you would like something similar to what we have for money in the table component ? https://sql-page.com/component.sql?component=table

Show the values with a certain format, but sort them according to their natural order, not to the format string ?

That is not yet implemented, but wouldn't be hard to do, reusing the same logic as we have for money columns. Pull requests welcome ! The code you will need to update is here: https://github.com/sqlpage/SQLPage/blob/main/sqlpage/sqlpage.js#L42

@lovasoa lovasoa changed the title table handlebars datetime formatting with natural sorting in the table component May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants