Allow configuration of text alignment for number/text cells
See original GitHub issueNumbers are usually right aligned in spreadsheet software (e.g. Excel and Google Sheets) since it makes it easier to compare numbers:
I would love to have an option in glide-data-grid as well to right-align the rendered text in a cell. I build my own custom cell to do this using the textAlign
canvas configuration, but I love to have this integrated directly into the core of glide-data-grid. I think there are two good options for this:
-
Option 1 (preferred): Provide the text alignment as part of the theme. This would allow the most flexibility since the theme can be already overwritten for any column, row, or individual cell.
-
Option 2: Provide an alignment property for
NumberCell
(or other text-based cells) which is applied to that cell.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Align text in Numbers on Mac - Apple Support
In Numbers on your Mac, align or justify paragraphs vertically and horizontally in a column, table cell, text box, or shape.
Read more >Align text in a cell - Microsoft Support
Select the cells that have the text you want aligned. On the Home tab choose one of the following alignment options: Alignment of...
Read more >Excel format for number, text, scientific notation, accounting, etc.
How to format cells in Excel (number, text, scientific notation, etc.) ... The below screenshot shows the default Alignment tab settings:
Read more >Excel XP: Text and Cell Alignments - GCF Global
The fourth type of cell alignment in the Format Cells dialog box is text orientation, which allows text to be oriented 90 degrees...
Read more >Formatting Numbers as Text - LibreOffice Help
... filteraligning -- cellsaligning -- objectsaligning -- paragraphsaligning ... layout -- definitioncomplex text layout -- enablingcomplex text layout, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is now in 4.0.4
So after some digging about I think the solution is to provide both a textDirection and textAlign in the base cell. Changing this may have some serious performance impacts if it changes regularly from cell to cell when scanning column by column. This is because the cavnas will reload the font each time if that happens. Also mixed textDirection and textAlign (e.g rtl + right align) cannot be done without measuring the text which will also introduce some mild overhead. This should not impact default options but its worth knowing.