0

I am using ngx-datatable. Sorting is not working if the column name having special and camel characters in it.

For example :

In table I am having the following columns needs to be sorted:

  1. displayName
  2. first_name

Please can anyone provide me the solution?

Thanks and Regards

Shilpa Kulkarni

user8030367
  • 81
  • 4
  • 18

2 Answers2

0

sorry I do not post a comment yet, I just relate my experience, I have worked with this grid, this is awesome, but I migrate to primeNG is best solution and are more flexible to work.

seeAlex
  • 31
  • 7
-1
<ngx-datatable-column *ngFor="let col of columns" name="{{col.name}}" prop="{{col.prop}}" class='{{col.prop}}' [sortable]="false" [cellClass]="getCellClass">
<ng-template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
                        <span class="datatable-header-cell draggable unselectable" (click)="onSort($event,col.prop, col.sortAscending = !col.sortAscending)" title="{{col.desc}}">
                            {{col.name}}
                        </span>                       
                    </ng-template>
</ngx-datatable-column>

public columns: Array<any> = [
        { name: 'Display Name', prop: 'displayName', sortAscending: false }, 
        { name: 'First Name', prop: 'first_name', sortAscending: false }, 
        ];

private onSort(event: any, column: string, sortingType: boolean) {
//here update the resilt rows as per assending or desc
}
vikas biradar
  • 238
  • 1
  • 3
  • 12