Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date is not sorting #152

Open
nandhuems opened this issue Mar 19, 2018 · 1 comment
Open

Date is not sorting #152

nandhuems opened this issue Mar 19, 2018 · 1 comment

Comments

@nandhuems
Copy link

I have Date Format like "01-03-2018". but the angular2-datable is not sorting correctly. the date is sorting based on the first digit.

@jmarlett93
Copy link

jmarlett93 commented Apr 19, 2018

To sort by date you need to add parsing information in the template syntax that matches your date syntax.
Table specifies "deliveryDate":

<table class="table table-condensed table-striped text-center" [(mfSortBy)]="deliveryDate" [(mfSortOrder)]="sortOrder" [mfData]="data" #mf="mfDataTable">

Header specifies with the "by" directive:

<thead><tr><th class="text-center"><mfDefaultSorter by="deliveryDate"><span>Order Date</span</mfDefaultSorter></th>

And in the tbody the crucial template parsing information:

<tbody><tr *ngFor="let item of mf.data"><td ><span>{{item.deliveryDate | date: 'MM-dd-yyyy'}}</span></td></tr></tbody>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants