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 :)
更多推荐
发布评论