StringResult+format doesn't seem to work in Webix datepicker

拥有回忆 提交于 2019-12-25 07:27:48

问题


I expect that stringResult will give me an output that corresponds to the specified format, but it always looks like YYYY-MM-DD HH:MM

Full code here.

For example, I've tried the following config:

{   
  view:"datepicker", 
  stringResult:true, 
  format:"%Y-%F-%d"      
},

But the output is still the same. So, is it a bug? Or am I doing something wrong? Thank you in advance!


回答1:


[Updated]

As mentioned by Loj, I agree with it. Thus, there are 2 solutions possible:

1. Custom Format

The format property you have used sets a date format to display in the datepicker field. So, it is just the display format and it is not actually formatted. Hence, the stringResult returns date as string with the default format. In order to get the custom date in the output, you are required to add your custom format which will convert the date in the desired format.

var format = webix.Date.dateToStr("%Y-%F-%d");

Check the snippet here.

2. Using getText()

Using stringResult property in the control's configuration makes the getValue method to return raw unformatted value. Hence, instead you should use the getText() as

$$("custom").getText();

in your code to get the formatted output via stringResult.



来源:https://stackoverflow.com/questions/39982162/stringresultformat-doesnt-seem-to-work-in-webix-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!