【发布时间】:2019-09-19 10:53:00
【问题描述】:
我正在尝试使用 Jquery "Datatables" 对表中的日期进行排序。
这是我写的html/php:
<td><input id='".$row['id']."' class='delivery_date ".$flatpickr."' data-io='edit' data-date='".$row['delivery_date']."' value='".$row['delivery_date']."' style='color: ".$color."'/></td>
我正在使用“Flatpickr”让用户更改列/单元格中的日期,结果如下:
<td><input id="69" class="delivery_date flatpickr flatpickr-input active" data-io="edit" data-date="2019-10-04" value="2019-10-04" style="color: " type="text" readonly="readonly"></td>
我找到了“Datatables”这个插件,它会搜索输入的“Dom-text”。
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
$.fn.dataTable.ext.order['dom-text-numeric'] = function ( settings, col )
{
return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
return $('input', td).val() * 1;
} );
}
这个插件没有任何反应。它不起作用,我没有收到任何错误消息。
还有另一个用于对“选择”进行排序的插件,它可以作为一种魅力。
我错过了什么?
这就是我想做的事情:
https://datatables.net/examples/plug-ins/dom_sort.html
【问题讨论】:
标签: jquery datatables flatpickr