Custom sorting in ngTable using AngularJs -
i looking forward custom sorting in ngtable, according http://ng-table.com/#/
replacing default sorting algorithm custom sort still pending. in case, want sort dataset respect days of week i.e, starting monday , ending @ sunday.
there way this?
kind of , suggestions appreciated.
on day, have column display 1 property , sort on another. suggest having object dayname , daysort, dayname day of week ("monday") , daysort sort order (1). see working codepen below.
http://codepen.io/storytimesolutions/pen/nndvzo
table:
<table ng-table="demo.tableparams" show-filter="true" class="table table-bordered table-striped"> <tr ng-repeat="row in $data track row.id"> <td title="'day of week'" filter="{dayname: 'text'}" sortable="'daysort'">{{row.dayname}}</td> <td title="'workout'" filter="{workoutplan: 'text'}" sortable="'workoutplan'">{{row.workoutplan}}</td> </tr> </table>
stubbed data:
data: [ {id: 1, dayname: "monday", daysort: 1, workoutplan: "run"}, {id: 2, dayname: "thursday", daysort: 4, workoutplan: "swim"}, {id: 3, dayname: "friday", daysort: 6, workoutplan: "jog"}, {id: 4, dayname: "friday", daysort: 6, workoutplan: "tennis"}, {id: 5, dayname: "saturday", daysort: 7, workoutplan: "volleyball"} ]
Comments
Post a Comment