cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the date format in Table -Column level in SAPUI5

Jayakrishnan
Active Participant
0 Kudos

Hi Friends,

     I am Working on the Custom SAPUI5 Application Development.(Master-Detail Page). In my application I have to display the Delivery Date Value at

Table view. I have successfully achieved that. see the screen shot below for your reference.

But Now I would like to change the Deliv Date Format ( 27.08.2014 to Aug 28,2014 ).

I have tried some solutions, but nothing works for me, if change anything it will not getting displayed.

These are the steps I have tried at my Detail.view.xml.





Accepted Solutions (0)

Answers (2)

Answers (2)

Qualiture
Active Contributor
0 Kudos

Your source pattern is wrong. It should be yyyy.MM.dd

Jayakrishnan
Active Participant
0 Kudos

Thank you all. But i am using XML View type for my Detail screen. and i have set the model data like this.

<Table headerText="Items" items="{GET_PR_Details}">.

once i set it at the header level ,then i am directly calling all my required data and seeting to the  table column like  below.

<Text text="{Ordered}" />

  <Text text="{CreatedBy}" />

  <Text text="{PR_REQUESTER}" />.

That is why i am getting confused.

Thank you

santhu_gowdaz
Active Contributor
0 Kudos

Just a guess, try like this,

  <DatePicker editable="false"

  value="{path:'DelivDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'long'}}" />

Jayakrishnan
Active Participant
0 Kudos

Hi All, Thank you for your response. I have completed 50% of the functionality by using Formatter code.

<Text

  text="{

  path:'DelivDate',

  formatter:'sap.ui.custom.prtracking.util.Formatter.date'

  }"/>

this is my code, i am calling the Formatter (js) from this view. but the object which am passing to formatter is raw type i guess. i am getting the response like Nan0,Nan .

this is my Formatter code:

date : function (value) {

  alert("inside date "+value);

  if (value) {

  var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "MMM dd,YYYY"});

  return oDateFormat.format(new Date(value));

  } else {

  return value;

  }

  },

i need to convert the value to number type. how do i acheive this?

Thanks

JK

santhu_gowdaz
Active Contributor
0 Kudos

what you are getting in "  alert("inside date "+value);"??

former_member256102
Discoverer
0 Kudos

Hi. Instead of


var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "MMM dd,YYYY"});

Try:


var oDateFormat = sap.ui.core.format.DateFormat.getInstance({pattern: "MMM dd, YYYY"});

May be this helps. Thanks

santhu_gowdaz
Active Contributor
0 Kudos

Exact solution for your problem,

santhu_gowdaz
Active Contributor
0 Kudos

valueFormat="yyyy-MM-dd" displayFormat="long"

2nd, 4th, 5th example in this-SAPUI5 Explored

Jayakrishnan
Active Participant
0 Kudos

Hi Santhosh,

Thanks for your reply. But Unfortunately it is not working.

i guess there is something wrong at the path , isn`t?. but if i  declare  as

<Text text="{DelivDate}"/> it is displaying 27.08.2014.

i have implemented your idea like below:

<ColumnListItem type="Navigation" press="handleLineItemPress">

  <cells>

  <Text text="{PreqItem}" />

  <Text

  text="{path:'DelivDate', type:'sap.ui.model.type.Date', formatOptions: { style: 'long'}}" />

  <Text text="{Ordered}" />

  <Text text="{CreatedBy}" />

  <Text text="{PR_REQUESTER}" />

  </cells>

  </ColumnListItem>

Thank you,

JK

santhu_gowdaz
Active Contributor
0 Kudos

DelivDate should be in "new Date()" format. means dn't format it to display like "27.08.2014".

it should display the system date.


  oModel.setData({
  dateValue: new Date()
  });