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.

Can I override just one table header and not all?

See original GitHub issue

Hi, Can I override just one table header and not all? I want a sortable table with a custom first column (a fancy checkbox first column). Right now all the logic in the sorting is in tbody > tr. I do not have thead > th and this is how my code looks like:

<tbody>
  <tr ng-repeat="foo in fooList">
    <td data-title="'Name'" class="" data-sortable="'name'">

And now my code looks like this

<thead>
<!--custom first column header-->
<!--boilerplate header-->
  <th ng-class="{
    'sort-asc': tableParams.isSortBy('name', 'asc'),
    'sort-desc': tableParams.isSortBy('name', 'desc')
    }"
    ng-click="tableParams.sorting({'name' : tableParams.isSortBy('name', 'asc') ? 'desc' : 'asc'})">
    <div>Name</div>
  </th>
<!--the rest of the column definitions which are similar to the previous one-->
</thead>
<tbody>
  <!--custom first column data-->
  <tr ng-repeat="foo in fooList">
    <td data-title="'Name'" class="" data-sortable="'name'">

I did so because I followed this example: http://bazalt-cms.com/ng-table/example/18 Is there any way I can have a simple default sortable column (like I used to have in my first example) and have custom stuff only in the first one? I have lots of columns and the boilerplate sortable stuff complicates my code a lot and it is not DRY.

A workaround is to make my own custom directive for the header but I was hoping there is a simpler solution.

Thank you!

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
Jeremy-Waltoncommented, Mar 3, 2015

Yes you can.

Create a simple custom template like so:

<script id="expandAllHeader" type="text/ng-template">
  <span class="expandable" ng-click="toggleExpandAll()">+ / -</span>
</script>

Then define your special column like this:

<td header="'expandAllHeader'">...</td>

… instead of this:

<td data-title="'whatever'">...</td>
0reactions
vcmirandacommented, Feb 27, 2019

Yes you can.

Create a simple custom template like so:

<script id="expandAllHeader" type="text/ng-template">
  <span class="expandable" ng-click="toggleExpandAll()">+ / -</span>
</script>

Then define your special column like this:

<td header="'expandAllHeader'">...</td>

… instead of this:

<td data-title="'whatever'">...</td>

Wonderful. Still useful!!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I override css class for header row only but keep rest ...
Simply remove the first row's class from the selector, using the :not () ... You can use the same concept to the other...
Read more >
Table panel: Column header overrides are ignored #18711
On 6.3.3. it is not possible to override column headers when using the table panel. This query should show Erzeugung and Bezug as...
Read more >
Overriding a Row or Column Heading
To override a specific row or column heading in the grid: ... In Heading Row Properties or Heading Column Properties, select Custom Heading,...
Read more >
A table with both a sticky header and a sticky first column
Here's a video example of a table that sticks both the header and first column: Why would you do that?
Read more >
Adding headers and footers to table sections - Apple Developer
Custom header and footer views give the sections of your table a unique appearance. With custom headers and footers, you specify the views...
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