on 02-02-2016 10:30 AM
Hello Experts,
I need to perform some logic AFTER each sort.
I'm aware to the 'sort' event of the table but it's called BEFORE the actual sort.
How can I implement it?
Regards,
Omri
Solved it on my own by calling the sort event, sort manually and then running my custom code after sort.
pseudo code (not handles sort direction etc)
onSort : function(oColumn) {
var oTable = oColumn.getSource();
var oColumn = oColumn.getParameter("column");
var oSorter = new sap.ui.model.Sorter(oColumn.getSortProperty(), false);
oTable.getBinding("rows").sort(oSorter);
for ( var i = 0; i < oTable.getColumns().length; i++) {
oTable.getColumns()[i].setSorted(false);
}
oColumn.setSorted(true);
// run custom code
}
Omri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Omri,
Resolved it in an other way and keeping sortProperty="<property>" on the xml view.
The following explaination is working but if you have more complex column selection fonctions, the state management will need to be updated to avoid false true.
The trick is to store the selected column and manage a "sort state".
When a column is selected we store it and update the sort state to true.
When the sort Ascending or Descending is selected the sort begins and the state is updated to false BEFORE sorting to avoid infinite loop.
Added in my controller:
1 - onInit
this.oTableSortColumn = null;
this.oTableSortState = false;
this.oTable.attachSort(this.sortAllColumns);
this.oTable.attachColumnSelect(this.updateColumnContext);
2 - updateColumnContext
this.oTableSortColumn= oEvent.getParameters().column;
this.oTableSortState = true;
3 - sortAllColumns
if(vc.oTableSortState ) {
this.oTableSortState = false;
/* Do your sorting stuff here like
* this.oTable.sort(this.oView.byId("columnID"), library.SortOrder.Ascending, true);
* or
* this.oTable.sort(this.oTableSortColumn, library.SortOrder.Ascending, true);
*/
}
Regards,
Rémi Pallier.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.