lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

Sorting with asynchronously received data #769

Closed blackhearted closed 7 years ago

blackhearted commented 7 years ago

If data is received asynchronously and not available at the moment of table creation - table is sorted differently.

Data "received" $scope.displayed.push({ firstName: "A1", balance: 300 }); $scope.displayed.push({ firstName: "A2", balance: 200 }); $scope.displayed.push({ firstName: "A3", balance: 100 });

If it is within $timeout table will look like. Note sorting icon on balance column is wrong: http://plnkr.co/edit/8B0Jy8bq1BDPdnU6bFGl?p=preview first name balance A1 300 A2 200 A3 100

If it is synchronous: http://plnkr.co/edit/ruf2LunDF3pQUMXCD0Zz?p=preview first name balance A3 100 A2 200 A1 300

MrWook commented 7 years ago

Hello @blackhearted,

In the Sort section of the documentation you can see that st-sort-default can have "true" or "reverse" as a value not "default" like in your example. Also if you want to use a asynchronously call to receive data you need to use st-safe-src like in the second section of The Basic