Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Table header click fire twice

$
0
0

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.


Viewing all articles
Browse latest Browse all 6178

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>