jQuery,DataTables,具有可编辑日期的列从服务器获取的数据的日期(jQuery, DataTables, column with editable Date for data obtai

编程入门 行业动态 更新时间:2024-10-24 00:19:40
jQuery,DataTables,具有可编辑日期的列从服务器获取的数据的日期(jQuery, DataTables, column with editable Date for data obtained from server)

aoColumns属性提供了使用DataTable设置表格中的列类型的可能性。

如果类型是textarea ,则没有问题,但是如何设置' Date '的类型以显示正确的日期值,并在特殊编辑器中为datepicker等日期值编辑它。

我用于以下链接的测试和知识示例:

http://www.script-tutorials.com/datatables-data-from-ajax-edit-in-place/

因为远程编辑数据库表是我的需求之一。

我想要使​​用和改进的代码的一小部分在这里:

'aoColumns': [ { type:'textarea', }, { type: 'select', data: "{'1':'true','0':'false'}", submit: 'Ok', }, { type: 'date' //********* here is my problem }, ]

aoColumns property offers possibility for setting type of columns rendering in table using DataTable.

There are no problem if the type is textarea, select but how can I set type for 'Date' for showing properly date value and edit it in special editor for date valuse like datepicker.

I use for testing and knowledge example from link below:

http://www.script-tutorials.com/datatables-data-from-ajax-edit-in-place/

because remote editing database table is one of my needs.

Small part of code I want to use and improve is here:

'aoColumns': [ { type:'textarea', }, { type: 'select', data: "{'1':'true','0':'false'}", submit: 'Ok', }, { type: 'date' //********* here is my problem }, ]

最满意答案

如果您不使用或不想使用任何第三方插件,请尝试将其渲染为简单文本框,并将类应用于您尝试应用日期选择器的列

'aoColumns': [ { sClass: 'dateField' } ]

使用简单的jquery使其成为一个datepicker,如下所示:

$(document).on("focus",".dateField",function(){ if ($(this).is("input[type=text]")) { $(this).datepicker(); } });

如果您更喜欢datepicker中的任何其他设置,那么您可以通过Jquery Datepicker并简单地将设置应用为普通的jquery datepicker。

希望这可以帮助 :)

If you aren't using or n't prefering to use any third party plugin, then try Rendering it as simple textbox and apply a class to the column where you are trying to apply the datepicker

'aoColumns': [ { sClass: 'dateField' } ]

Use simple jquery to make it a datepicker as below :

$(document).on("focus",".dateField",function(){ if ($(this).is("input[type=text]")) { $(this).datepicker(); } });

If you prefer any other settings in datepicker then you can go through Jquery Datepicker and can simply apply the settings accordingly as normal jquery datepicker.

Hope this helps :)

更多推荐

本文发布于:2023-07-08 19:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1080220.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   编辑   服务器   数据   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!