Hi,
I have one table to which I have binded to user data.
Instead of specifying sortProperty, I want, when user click on header it should default sort with ASC and then DESC and so on. So in header label, I attacheBrowserEvent as follow
oColumn = new sap.ui.table.Column("colUserDesc",{
label: new sap.ui.commons.Label({text: "Description"}).attachBrowserEvent("click",function(event){
oController.sortUserList('colUserDesc');
}),
template: new sap.ui.commons.TextView().bindProperty("text", "Description"),
width: "255px"
});
oTable.addColumn(oColumn);
but sortUserList - event get fire twice when user click once. because of which column get sorted to DESC order always(first time get sorted to ASC order and 2nd time DESC).
following is sortUserList Function define in controller
sortHQDeals:function(columnId) { var col = sap.ui.getCore().byId(columnId); var tbl = sap.ui.getCore().byId("tblUsers"); if(col.getSorted()) { if(col.getSortOrder() == sap.ui.table.SortOrder.Ascending) { tbl.sort(col,sap.ui.table.SortOrder.Descending); } else { tbl.sort(col,sap.ui.table.SortOrder.Ascending); } } else { tbl.sort(col,sap.ui.table.SortOrder.Ascending); } },
I don't know why event is firing twice.
Any help is appreciated.
Thanks in advanced.