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

Doesn't sort by timestamp by default #796

Open
ghost opened this issue Oct 5, 2017 · 1 comment
Open

Doesn't sort by timestamp by default #796

ghost opened this issue Oct 5, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 5, 2017

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.

@ghost ghost changed the title Doesn't sort by datetime default Doesn't sort by timestamp by default Oct 5, 2017
@lorenzofox3
Copy link
Owner

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

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

1 participant