user interface - I cannot format the date in the way I want in sap.m.DatePicker -


i have couple of weird problems sap.m.datepicker. do, searched topics via google, helped me, not entirely.

what want achieve: have sap.ui.table.column in sap.ui.table.table , column should have template: new sap.m.datepicker() date formatted dd.mm.yyyy.

what have done far: using sap.ui.model.odata.v2.odatamodel() populate sap.ui.table.table odata service. went until decided have dates in corresponding column displayed in prefered format. @ first, using these properties, related formatting in datepicker's constructor:

displayformat: "dd.mm.yyyy", valueformat: "yyyy-mm-dd", //... value = "{" + fieldname + "}" 

in way, dates displayed in following format: sun aug 06 2017 03:00:00 gmt+0300 (fle daylight time) (i don't know how express using format string). remember yesterday reading in documentation, when have binding, displayformat ignored, me ... don't understand why that.

anyway, found solution, gives advice set value this:

value: {                 path: colname,                 type: new sap.ui.model.type.date({                     pattern: "dd.mm.yyyy"                     //source: { pattern: "yyyy-mm-dd hh:mm:ss:fff" }                 })             } 

at first, seems work , date formatted , displayed correctly, when try modify date in row... example, choose august 6th 2017. saved database via odata service 2017-06-08 00:00:00.000 not august 6th june 8th. select august 2nd - in database see 2017-02-08 00:00:00.000 - february 8th. seems month , day switched. if select, example, august 30th, change not saved. far understand problem - there no month number 30, refuses save it. totally makes sense. :d

then tried add/uncomment line source: {}. every row date column shows empty, if every row in database has null value in date column.

next, tried remove displayformat: "dd.mm.yyyy", valueformat: "yyyy-mm-dd" definition of datepicker template - nothing changed. interesting - no matter if remove 2 lines or not, can still change date of row (the change gets saved database), although month , day still switched.

then came accross solution, said, should add formatter this:

value: {             path: colname,             formatter: function (val) {                 return sap.ui.core.format.dateformat.getdateinstance({ pattern: "dd-mm-yyyy" }).format(val);             }         }; 

this way, seems work should. may ask did give using format dd.mm.yyyy. answer "no!", doesn't work.

so, main question, want ask: what's wrong formatting? no matter other symbol use, comma, dash, works (dd-mm-yyyy or dd,mm,yyyy). dates displayed corresponding symbol. when try use dd.mm.yyyy, errors that: enter image description here , that: enter image description here

thank help! appreciate it!

edit: have come idea workaround issue. unfortunately, doesn't work , produces exact same error, described above pictures. here nonworking solution: return sap.ui.core.format.dateformat.getdateinstance({ pattern: "dd-mm-yyyy" }).format(val).replace(/\-/g, '.');

try using "datevalue" + "displayformat" properties here:

https://plnkr.co/edit/wkhv9s?p=preview

<datepicker     datevalue="{testmodel>/mydate}"     displayformat="dd.mm.yyyy" /> 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -