question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to format table head cell individually (cells with labels)?

See original GitHub issue

Hey everyone,

Using mui-datatables 2.0.0-beta.59 and I’m wondering: is there a way to format the table head cells individually (the label cells)?

Use case: I want to left-align the content of certain columns and right-align others. I can do that because I can display JSX in the table cells. But then the column title is out of alignment with the content.

I can only specify column labels as text. If I use JSX as a label, the app crashes if I click on the table head cell (might have to do something with the sorting arrow being added at that time).

Any solution? Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
zeeshansafdar48commented, Jun 27, 2019

@dandrei Thanks. I really need this.

0reactions
dandreicommented, May 15, 2019

Turns out it was really easy to do:

customHeadRender: (o, updateDirection) => {
    return <th onClick={() => updateDirection(o.index)} style={{fontWeight: 400, cursor: "pointer"}}>
        {o.label}
        <TableSortLabel active={o.sortDirection !== null} direction={o.sortDirection || "asc"}/>
    </th>;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tables with Two Headers | Web Accessibility Initiative (WAI)
Table with header cells in the top row and first column ... In the example below, the “Open” and “Closed” labels are only...
Read more >
Format a table - Microsoft Support
Add table borders to specified cells only · On the Home tab, in the Paragraph group, click Show/Hide. Word Ribbon image · Select...
Read more >
Working with Worksheet Tables — XlsxWriter Documentation
Tables can have column headers, autofilters, total rows, column formulas and ... to populate the cells or if you wish to modify individual...
Read more >
Working with Tables in GitHub Markdown - Pluralsight
HTML tags can be used for additional formatting inside individual cells. The Header. The header of a markdown table consists of two rows....
Read more >
How to Independently Conditionally Format Table Columns in ...
Once the Edit Axis pop-up screen appears, change the 'Title' field entry to give the column a reasonable label name. The edit axis...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found