Quantcast
Channel: SCN: Message List - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 8124

Re: Add data in xml view

$
0
0

Hi Pranay,

 

You can use calculated fields for data binding and use two fields with a formatter. This is how they can be used:

 

parts : [

    {path : 'leavedatefrom'},

    {path : 'leavedateupto'},

],

formatter : function(leavedatefrom,leavedateupto){

     var substracted = "";

     // substract dates according to your requirement

     return substracted;

}


You have to set bindingSyntax to complex for this to work:


data-sap-ui-xx-bindingSyntax="complex"

 

Difference in days between dates can be calculated with:

 

var daysBetween = function( date1, date2 ) {

  //Get 1 day in milliseconds

  var one_day=1000*60*60*24;

 

  // Convert both dates to milliseconds

  var date1_ms = date1.getTime();

  var date2_ms = date2.getTime();

 

  // Calculate the difference in milliseconds

  var difference_ms = date2_ms - date1_ms;

  

  // Convert back to days and return

  return Math.round(difference_ms/one_day);

}

 

Regards,

Kimmo


Viewing all articles
Browse latest Browse all 8124

Trending Articles



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