简体   繁体   English

如何为杂货店添加时间选择器

[英]How to add a time picker to grocery crud

I have two types of date time fields in my database. 我的数据库中有两种类型的日期时间字段。 DATE and TIME. 日期和时间。 With the DATE field Grocerycrud gives you a date picker when adding a record. 使用DATE字段,Grocerycrud在添加记录时为您提供日期选择器。 With the TIME field Grocerycrud only gives you a text field. 使用TIME字段,Grocerycrud仅提供一个文本字段。

Is there any way to get Grocerycrud to show a time picker for TIME fields? 有什么方法可以让Grocerycrud显示TIME字段的时间选择器?

Use a datetime field instead and you'll get the datepicker and timepicker altogether. 改用datetime字段,您将同时获得datepicker和timepicker。

If you wish to use only time fields you'll have to modify GC. 如果只希望使用时间字段,则必须修改GC。 This is not the correct way to extend GC but as development seems stopped I guess its ok. 这不是扩展GC的正确方法,但是由于开发似乎已停止,我猜它还可以。

Follow the instrucction from this post: http://www.grocerycrud.com/forums/topic/1573-timepicker-implementation/#entry11462 请遵循这篇文章的说明: http : //www.grocerycrud.com/forums/topic/1573-timepicker-implementation/#entry11462

After a long search and following through the above documentation which didn't work for me I devised my own solution. 经过长时间的搜索并仔细阅读了上面对我来说不起作用的文档,我设计了自己的解决方案。 Convert the type of input field to time using jquery. 使用jquery将输入字段的类型转换为时间。 It was sufficient for me although its not a robust method. 尽管这不是一种可靠的方法,但对我来说已经足够了。 It may help in certain situations at least 至少在某些情况下可能会有所帮助

<script type="text/javascript">

$( document ).ready(function() {
      var a = document.getElementById("field-ScheduledTime");
    a.type="time";                      
});
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM