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.

Sorting with custom template - click handler doesn't seem to 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, post on Stackoverflow or Gitter

Current behavior

Looks a lot like https://github.com/swimlane/ngx-datatable/issues/431 custom column template with server side pagination on sort function is (sort)="onPageSorted($event)" and column is defined as

 <ngx-datatable-column  name="ID" [resizeable]="false" [sortable]="true" [flexGrow]="1">
        <ng-template let-column="column" ngx-datatable-header-template>
        {{column.name}}
        </ng-template>
        <ng-template let-value="value" ngx-datatable-cell-template>
           <strong>{{value}}</strong>
        </ng-template>
    </ngx-datatable-column>
 

Expected behavior

on click on the column header will trigger the event

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Table version: 0.8.x

9.3.0

  • Angular version: 2.0.x

4.1.3

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

  • Language: [all | TypeScript X.X | ES6/7 | ES5] TypeScript 2.3.4

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:11
  • Comments:19

github_iconTop GitHub Comments

36reactions
gyulauszkaicommented, Jun 20, 2017

True…but if you do this, it will work: https://github.com/swimlane/ngx-datatable/issues/681#issuecomment-297386597

In your case

<ngx-datatable-column  name="ID" [resizeable]="false" [sortable]="true" [flexGrow]="1">
        <ng-template let-column="column" ngx-datatable-header-template let-sort="sortFn">
 <span (click)="sort()">
        {{column.name}}
</span>
        </ng-template>
        <ng-template let-value="value" ngx-datatable-cell-template>
           <strong>{{value}}</strong>
        </ng-template>
    </ngx-datatable-column>
21reactions
kedar700commented, Apr 20, 2018

Use this

<ng-template let-column="column" let-sort="sortFn" let-sortDir="sortDir" ngx-datatable-header-template>
<span class="mobile-hidden" (click)="sort($event, sortDir, sortFn)">{{column.name}}</span>
</ng-template>

this works now. even if you do not provide the implementation for the sort function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why click event handler doesn't work after sorting the table
I'm using jQuery DataTables and I have a table which is generated using a foreach loop. In each row generated, 2 buttons are...
Read more >
Custom sorting a slicer does not work
Hello all, For some strange reason, I suddenly cannot sort a slicer using a custom list. I create the list, double click on...
Read more >
Kendo Grid with Column Templates not sorting correctly - Telerik
Hi, I have a Kendo Grid with column templates to handle date formatting, ... the prefix does not appear until unless clicked on...
Read more >
Views, filters & sorts – Notion Help Center
Sorts · Click Sort at the top right of your database. · In the dropdown that appears, choose the property you'd like to...
Read more >
How to alphabetize in Excel: sort columns and rows A-Z or Z-A
I tried creating a custom list "A,B,C,... etc... .. X,Y,Z,0,1..list but this does not appear to work as I have Value AA00 before...
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