Skip to content

Up or down arrow appears next to column header when the data is sorted #149

Open

Description

@pratiksha-chandel

NOt working as expected . what change expected here?

import {Component, Input, OnInit} from "@angular/core";
import {DataTable, SortEvent} from "./DataTable";

@component({
selector: "mfDefaultSorter",
template: <a style="cursor: pointer" (click)="sort()" class="text-nowrap"> <ng-content></ng-content> <span *ngIf="isSortedByMeAsc" class="glyphicon glyphicon-triangle-top" aria-hidden="true"></span> <span *ngIf="isSortedByMeDesc" class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> </a>
})
export class DefaultSorter implements OnInit {
@input("by") sortBy: string;

isSortedByMeAsc: boolean = false;
isSortedByMeDesc: boolean = false;

public constructor(private mfTable: DataTable) {
}

public ngOnInit(): void {
    this.mfTable.onSortChange.subscribe((event: SortEvent) => {
        this.isSortedByMeAsc = (event.sortBy == this.sortBy && event.sortOrder == "asc");
        this.isSortedByMeDesc = (event.sortBy == this.sortBy && event.sortOrder == "desc");
    });
}

sort() {
    if (this.isSortedByMeAsc) {
        this.mfTable.setSort(this.sortBy, "desc");
    } else {
        this.mfTable.setSort(this.sortBy, "asc");
    }
}

}

Activity

  1. kevinding0218 commented on Feb 14, 2018

    @kevinding0218

    @pratiksha-chandel you can do as following:
    step 1: check if you have "glyphicon" installed in your application,
    step 2: remove "aria-hidden="true" from DefaultSorter.ts
    step 3: try to replace it with "fa fa-sort-up" or "fa fa-sort-down"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions