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.

Pipes inside of Column Headings don't work

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior Whenever a column name’s associated value (for instance a class attribute in the component) changes, the column name doesn’t change.

Expected behavior The column name should change as well.

Reproduction of the problem (You don’t get a plunkr from me, since your template: http://plnkr.co/edit/TLx2vYlCTLsqcLwvWafd is broken and I cannot find ngx-datatable on unpkg).

<ngx-datatable class="material" [rows]="data" [headerHeight]="50"
               [footerHeight]="50" [rowHeight]="'auto'" [externalSorting]="true" [loadingIndicator]="loading"
               (sort)="onSort($event)">
    <ngx-datatable-column [name]="columnName" [flexGrow]="3">
        <template let-value="value" ngx-datatable-cell-template>
            {{value}}
        </template>
    </ngx-datatable-column>
</ngx-datatable>

<button (click)="toggleColumnName()">Toggle Column Name</button>
public loading: boolean = false;
public columnName: string = "ABC";

public data: Array<any> = [
    {
        firstColumn: "123"
    }
];

public onSort($event): void {
}

public toggleColumnName(): void {
    this.columnName = this.myAwesomeColumnName == "ABC" ? "DEF" : "ABC";
}

What is the motivation / use case for changing the behavior? I want to use ng2-translate’s TranslatePipe, but whenever the language changes, the corresponding column name doesn’t change. I know about https://github.com/swimlane/ngx-datatable/issues/376, but like I said: when the translation changes, the column doesn’t change.

  • Table version: 6.0.0 (latest)

  • Angular version: 2.0.x 2.4.5 (latest)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:9
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
sundriedtunacommented, Mar 28, 2017

Is there a known workaround for this issue? I need to be able to use ng2-translate to change the language of the column headers dynamically.

Edit: Found a workaround. Pipes will only work correctly if they are within a header template. So, for example,

<ngx-datatable
                class="material"
                [rows]="rows"
                [columns]="columns"
                [columnMode]="'force'"
                [headerHeight]="25"
                [footerHeight]="36"
                [rowHeight]="36"
                [offset]="currentPage"
                [limit]="limit"
                (page)="onChange($event)">
            <ngx-datatable-column name="{{columns[0].name}}" prop="{{columns[0].prop}}">
                <template let-column="column" ngx-datatable-header-template>
                   {{'jsonKey1' | translate}}
                </template>
                <template let-value="value" ngx-datatable-cell-template>
                   {{value}}
                </template>
            </ngx-datatable-column>
</ngx-datatable>
2reactions
javico2609commented, Jan 3, 2018

@sundriedtuna

i did trying that solution, it’s work fine for translate but lose the sort feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dplyr indirection / pipe doesn't work inside a closure
There is a problem with the pipes, specifically the pipe within the enclosed function. I guess there might be a scoping problem, ...
Read more >
Using Freeze Panes to Keep Row/Column Headings Visible ...
This video shows you to use Excel's Freeze Panes feature to keep you row and column heading on screen when scrolling through a...
Read more >
How to Insert a Header With Columns in Microsoft Word
Microsoft Word - Heading formatting and table of contents · MS Word - Working with Columns · MS Word - Header and Footer...
Read more >
Working with Tables in GitHub Markdown - Pluralsight
The first row is the column headers for the table. To specify the headers, simply separate each header with spaces and pipes.
Read more >
Top 10+ Mistakes of DWV plumbing design
Horizontal distance from trap weir to inner edge of vent shall be within distance in Table 10-1, but not closer than 2 times...
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