Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9129

Re: How to custom sort a list dynamically ?

$
0
0

Hi Rashchynski,

I have used the code u suggested and it is not working for me. I have pasted the code which i am using for testing. Plese check it and revert me back. Thanks in Advance.


Code:


onSortSelected : function(sKey) {

  if (sKey == "Priority") {

  var map = {"Very High" : 1, "High" : 2, "Medium" : 3, "Low" : 4};

  

  

  function get(k){

   return map[k];

  }

  

  

  var s = new sap.ui.model.Sorter("Priority");

  s.fnCompare = function(value1, value2) {

   var val1Mapped = get(value1);

   var val2Mapped = get(value2);

     if (val1Mapped < val2Mapped) return -1;

     if (val1Mapped == val2Mapped) return 0;

     if (val1Mapped > val2Mapped) return 1;

  };

 

  }

  else

  var s = new sap.ui.model.Sorter(sKey, true, false);

  var list = that.getView().byId("list");

  var binding = list.getBinding("items");

  binding.sort(s);

  }


Viewing all articles
Browse latest Browse all 9129

Trending Articles



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