Named MDX sort table

Hello Canvas Experts,

I’m creating a table using a Named MDX and would like to sort the table by one of the value columns returned (fixed sorting, no user interaction required), how can I do this? Is it possible using the ‘options’ section of the $tm1Ui.tableCreate function?

Thanks,
David

Hi @anz.fin.all.mailbox,

The Sortable, Filtered Table menu of the Canvas Samples application should be able to help you out on this.


Paul

Hi @plim,

I’ve looked at that sample already but struggling to see how to apply it in our example (my technical skills aren’t up to scratch).

In the table header I’m repeating data column labels as follows:

<th ng-repeat="col in row.columns" ng-if="col.visible" colspan="{{col.colspan}}" rowspan="{{col.rowspan}}" class="text-center">
	{{col.key}}
</th>

Then in the table body I’m repeating the data:

<td ng-repeat="cell in row.cells" class="text-right">
	{{cell.value | formatNumber:2}}
</td>

Inside this repeat is one column called “Metres” and I want to have a fixed sort on this column by ascending value. How is this possible?

Thanks,
David

Hi @anz.fin.all.mailbox,

Then you might just need to add an Angular order filter on the ng-repeat of the rows:

https://www.w3schools.com/angular/ng_filter_orderby.asp

https://docs.angularjs.org/api/ng/filter/orderBy

I am not sure of the contents of your model / variable, but it can potentially look like:

<tr ng-repeat="row in yourtabledata | orderBy:'Metres'">...</tr>

Or if it is like the 4th or 5th column in those cells:

<tr ng-repeat="row in yourtabledata | orderBy:'cells[4].value'">...</tr>

Let us know how it goes.


Cheers,
Paul

1 Like

Hi @plim,

I was able to get what I needed this time around by using your second suggestion, thanks so much!

Cheers,
David