on 06-30-2015 11:59 PM
Hi All,
I am trying to modify date format in a dialogue that is being called from view. following is the code from view and controller.
toolbar: new sap.ui.commons.Toolbar({
items: [
new sap.ui.commons.Button('edit_btn',{
text: "Edit Note",
icon: "sap-icon://edit",
enabled: false,
press: oController.editNotePress.bind(oController)
}),
Code from Controller:
var fileTable = sap.ui.getCore().byId('noteFileTable');
var json = JSON.parse(fileTable.getModel().getJSON());
for (var i = 0; i < indices.length; i++) {
var context = searchTable.getContextByIndex(indices[i]).getPath();
var model = searchTable.getModel();
var obj = model.getProperty(context);
obj.__metadata = null;
if (!doFilesContainFile(json.results, obj)) {
json.results.push(obj);
}
}
fileTable.getModel().setData(json);
fileTable.bindRows("/results");
addTableColumn(fileTable, "ACTIVATED_AT", "Activated at");
All I need to do is to modify "Activated at" field to display in format "yyyy-MM-dd HH:mm:ss.ms"
I have used date formatter at another place but its not working here. When I tried following code, the popup is not getting displayed.
addTableColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Activated at"
}),
//Date modification
template: new sap.ui.commons.TextView().bindProperty("text", {
path: 'ACTIVATED_AT',
type: new sap.ui.model.type.Date({pattern:"yyyy-MM-dd HH:mm:ss.ms"})
})
}));
Any help would be much appreciated.
Regards
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Uday,
Can you please rewrite the code like this and check,
template: new sap.ui.commons.TextView().bindProperty("text", {
path: 'ACTIVATED_AT',
formatter : function(value){
var oLocale = sap.ui.getCore().getConfiguration().getLocale();
var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({
style : "medium",
pattern : "yyyy-MM-dd HH:mm:ss.ms"
}, oLocale);
var date = new Date(value);
var oDate = oDateFormat.format(date);
return oDate;
}
})
Regards,
Sharique
type: new sap.ui.model.type.DateTime({pattern:"yyyy-MM-dd HH:mm:ss.ms"});
may this help you,
sap.ui.model.type.DateTime - User Interface Add-On for SAP NetWeaver - SAP Library
format - Formatting a date from an ODataModel in a SAPUI5 table - Stack Overflow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what is value of ACTIVATED_AT?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its an element from oData model. The value of the field is the system date and time when a particular record is created. The format of this date an time is "Tue Jun 30 2015 09:20:13 GMT-0700 (Pacific Daylight Time)", however, we want to display this date in the format "2015-06-30 09:20:13:2013".
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.