StringResult +格式在Webix datepicker中似乎不起作用 [英] StringResult+format doesn't seem to work in Webix datepicker

查看:157
本文介绍了StringResult +格式在Webix datepicker中似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 stringResult 将给出一个对应于指定的格式的输出,但它总是看起来像 YYYY-MM-DD HH:MM

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

这里的完整代码

例如,我尝试过以下配置:

For example, I've tried the following config:

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

但输出仍然相同。那么这是一个bug吗?还是我做错了?谢谢你提前!

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

推荐答案

[更新]

如Loj所说,我同意这一点。因此,有两种解决方案可行:

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

1。自定义格式

您所使用的格式属性设置日期格式显示在datepicker字段中。所以,它只是显示格式,并没有实际格式化。因此, stringResult 将日期作为默认格式的字符串返回。
为了在输出中获取自定义日期,您需要添加自定义格式,该格式将以期望的格式转换日期。

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");

检查代码段这里

2。使用getText()

在控件的配置中使用 stringResult 属性可使getValue方法返回未格式的原始值。因此,您应该使用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();

在您的代码中通过stringResult获取格式化的输出。

in your code to get the formatted output via stringResult.

这篇关于StringResult +格式在Webix datepicker中似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆