Hi,
Apologies in advance for posting on a topic that’s already been discussed but I’m really struggling to get a sortable table working with a named MDX as a table source and I need some help please.
Here is my table:
> $scope.dataset = $tm1Ui.resultsetTransform($rootScope.defaults.settingsInstance, “”, result, {alias: {“”:“EN Code and Name”}});
var options = {preload: true, watch: false}; if($scope.table){ options.index = $scope.table.options.index; options.pageSize = $scope.table.options.pageSize; } $scope.table = $tm1Ui.tableCreate($scope, $scope.dataset.rows, options);
It creates a simple table with three columns and a few hundred rows.
I’ve copied the setup of the HTML from the sample table:
> <thead> > <tr> > <th>Customer</th> > <th class="tm1-ui-sortable" ng-class="table.sortClass('Revenue')" ng-click="table.sort('Revenue')">Weekly Revenue Movement</th> > <th class="tm1-ui-sortable" ng-class="table.sortClass('Metres')" ng-click="table.sort('Metres')">Weekly Metres Movement</th> > </tr> > </thead> > <tbody> > <tr ng-repeat="row in table.data()"> > <td ng-repeat="el in row.elements" >{{el.alias}}</td> > <td ng-model="row.Revenue">{{row['weeklyrevenuemovement'].value | formatNumber:0}}</td> > <td ng-model="row.Metres">{{row['weeklymetresmovement'].value | formatNumber:0}}</td> > </tr> > </tbody>
When clicking on either the Revenue or Metres columns it does apply some kind of sort but not according to the values in the column, also, no matter what column is clicked the sort is the same.
What am I doing wrong? Can someone also please explain to me what the relationship is between the ng-class=“table.sortClass()” and ng-click=“table.sort()” in the table header and ng-model in the table body?
Many thanks,
David