Skip to content
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

Individual Column alignment #62

Closed
shopno111 opened this issue Dec 27, 2021 · 3 comments · Fixed by #63
Closed

Individual Column alignment #62

shopno111 opened this issue Dec 27, 2021 · 3 comments · Fixed by #63
Assignees
Labels
feature A new feature to be added question Something is not clear

Comments

@shopno111
Copy link

shopno111 commented Dec 27, 2021

Expected Behavior

Can we use specific alignment ?, if yes, then how we can do that.
Suppose I want to do right align in right with header and data .

@joaocarmo joaocarmo self-assigned this Dec 27, 2021
@joaocarmo joaocarmo added the question Something is not clear label Dec 27, 2021
@joaocarmo
Copy link
Owner

joaocarmo commented Dec 28, 2021

Hi @shopno111, you can use CSS to achieve what you want. Just add this snippet somewhere where your table is being rendered:

/* Targets the head `th` and the body `td` */
.rsdt th, .rsdt td {
  /* You you only need the !important rule if you're overriding some other CSS */
  text-align: right !important;
}

You can always use the .rsdt selector to target this library's table.

@shopno111
Copy link
Author

shopno111 commented Dec 29, 2021

as your way it will be all column, I want to do specific column only.

Example :
I have following columns
Name, Phone, Email, Date , Amount

Here Name, Phone, Email, Date will be Left Alignment & Amount will be Right Column

In your Headers, if we can do following way, it will be fetter

amount: {
text: "Amount",
sortable: true,
filterable: true,
headerClass: "rightAlign",
bodyClass: "rightAlign",
transform: (value, idx, row) => (
"$ "+value
)
}

headerClass = to styling table header part (th)
bodyClass = to styling table body cell like (td)

If we can use custom class in there it will be good

@joaocarmo
Copy link
Owner

joaocarmo commented Dec 30, 2021

If you know the position of the columns, you can also target that using CSS and the nth-of-type selector. For example:

/* Align the 3rd column's content to the right */
.rsdt th:nth-of-type(3), .rsdt td:nth-of-type(3) {
  text-align: right !important;
}

Though I understand the limitation. I'm considering adding a data attribute to the column (header and body rows) which you can then use to easily target using CSS:

/* Align the `amount` column's content to the right */
.rsdt th[data-column-name='amount'], .rsdt td[data-column-name='amount'] {
  text-align: right !important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature to be added question Something is not clear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants