Smart-Table icon indicating copy to clipboard operation
Smart-Table copied to clipboard

Doesn't sort by timestamp by default

Open Fossil01 opened this issue 6 years ago • 1 comments

See table structure below. I can manually sort by "Date / Time" (Third column) although I need to click it twice before it sorts descending.

Anyway. I want to have it sorted descending on date/time by default but the following code doesn't work. Any idea? The row.mea.created.timestamp looks like 2017-10-05T10:04:57.824428733Z

<table st-table="src" st-safe-src="json" class="table table-striped">
	<thead>
		<tr>
			<th st-sort="location.name">{{ 'location' | translate | capitalize }}</th>
			<th st-sort="device.name">{{ 'device' | translate  | capitalize }}</th>
			<th  st-skip-natural="true" st-sort-default="reverse" st-sort="created_at">Date / Time</th>
			<th st-sort="granted">Allowed</th>
			<th st-sort="card.type.name">{{ 'type' | translate | capitalize }}</th>
			<th st-sort="card.identity.surname">{{ 'name' | translate | capitalize }}</th>
			<th st-sort="card.company.name">{{ 'company' | translate  | capitalize }}</th>
		</tr>
		<tr>
			<th colspan="7"><input st-search="" class="form-control" placeholder="Search" type="text"/></th>
		</tr>
	</thead>
	<tbody>
		<tr ng-repeat="row in src">
			<td>
				<strong uib-popover-html="'{{row.device.location.name}}'" popover-append-to-body="true" popover-trigger="'outsideClick'">
				{{row.device.location.name | limitTo:30 }}{{ row.device.location.name.length > 30 ? '...' : ''}}
				</strong>
				<br />
				{{row.device.location.address}}
			</td>
			<td uib-popover-html="'{{row.device.name}}'" popover-append-to-body="true" popover-trigger="'outsideClick'">{{row.device.name | limitTo:30 }}{{ row.device.name.length > 30 ? '...' : ''}}</td>
			<td>{{ row.meta.created.timestamp | date : 'dd-MM-yyyy HH:mm:ss' : 'CET'  }}</td>
			<td><i class="fa fa-check text-success" ng-show="row.granted" aria-hidden="true"></i><i class="fa fa-times text-danger" ng-show="!row.granted" aria-hidden="true"></i></td>
			<td uib-popover-html="'<strong>Chipnumber: </strong>{{row.card.chipnumber}}'" popover-append-to-body="true" popover-trigger="'outsideClick'">{{ row.card.type.name }}</td>
			<td uib-popover-html="'{{ row.card.identity.initials }} {{ row.card.identity.surname}}'" popover-append-to-body="true" popover-trigger="'outsideClick'">{{ row.card.identity.initials }} {{ row.card.identity.surname | limitTo: 20 }}{{ row.card.identity.surname > 20 ? '...' : ''}}</td>
			<td uib-popover-html="'{{row.card.company.name}}'" popover-append-to-body="true" popover-trigger="'outsideClick'">{{row.card.company.name | limitTo:25 }}{{ row.card.company.name.length > 25 ? '...' : ''}}</td>
		</tr>
	</tbody>
	<tfoot>
	<tr>
		<td colspan="7" class="text-center">
			<div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="10"></div>
		</td>
	</tr>
	</tfoot>
</table>

[EDIT] Just tested but I can also not sort by default on other columns while it works manually.

Fossil01 avatar Oct 05 '17 09:10 Fossil01

Can you please provide a plunkr with angular and smart-table version you use (I am not able to reproduce) ? thanks

lorenzofox3 avatar Oct 05 '17 14:10 lorenzofox3