简体   繁体   English

jQuery Tablesorter日期选择器

[英]jQuery Tablesorter Date Picker

How would I go about the implementation of a date picker into Tablesorter so that I can show a result between to dates 01/01/2001 - 01/01/2012 ? 我怎么会去实施日期选择器进入的tablesorter,这样我能显示日期之间的结果01/01/2001 - 01/01/2012

I have been given the following question hence my query regarding the question above: 我收到以下问题,因此我对上述问题有疑问:

In HTML display a set of tabular data where the data contains dates. 在HTML中显示一组表格数据,其中数据包含日期。 Implement a date picker that filters the tabular data. 实现日期选择器,以过滤表格数据。 Where possible allow for the tabular data to be supplied via ajax or json feeds. 尽可能允许通过ajax或json feed提供表格数据。

As I commented before, you can do this by simply using 2 jQuery UI datepickers - one for min date, another for max date - and filtering the dates. 正如我之前评论的那样,您可以通过简单地使用2个jQuery UI datepicker (一个用于最小日期,另一个用于最大日期)并过滤日期来实现。

I've made an extremely simple example, Take a look . 我举了一个非常简单的例子, 看看 And here's the commented version (you can also type the numbers in conjunction with the datepickers, which may prove to be an easier way around). 这是带注释的版本 (您也可以将数字与日期选择器一起键入,这可能是一种更简便的方法)。

Now, if you want to load content dynamically inside of a div, you just have to take a look at the jQuery's Ajax documentation or read some tutorials - that's pretty basic stuff. 现在,如果要在div内部动态加载内容,则只需看一下jQuery的Ajax文档或阅读一些教程-这是非常基本的内容。

The simplest way to make your Ajax would be wrapping your table inside a div, say, tablewrapper then you can use the .load() jQuery method: 制作Ajax的最简单方法是将表包装在div之内,例如tablewrapper然后可以使用tablewrapper .load() jQuery方法:

$('#tablewrapper').load('UrlWhichContainsMyTable.html');

In the example above you'd echo a whole <table> ... </table> (or have it inside a html document). 在上面的示例中,您将回显整个<table> ... </table> (或将其包含在html文档中)。

If you want to load table rows dynamically, you can use .append and .appendTo methods to your table: 如果要动态加载表行,可以对表使用.append.appendTo方法:

$.get('urlWithMyNewRows.html', function(r){ //or $.post, $.ajax etc
      $('table.bordered').append(r);
});

In the example above, you'd fetch a collection of table rows <tr> to append to your table from your urlWithMyNewRows.html document. 在上面的示例中,您将从urlWithMyNewRows.html文档中获取表行<tr>的集合以追加到表中。

And take a look at $.getJSON documentation and examples if you need it. 并查看$ .getJSON文档和示例(如果需要)。 =] =]

ps. PS。 I call my fiddle "simple" as I didn't even validate if the maxdate is before the mindate to display an warning neither show a "No results found" message, even though those are just a couple lines of code as well. 我把小提琴叫做“简单的”,因为我mindate至没有验证maxdate是否在显示警告之前就没有显示“未找到结果”消息,即使这些也只是几行代码。

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

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