我有一个这样的局部 View :
<div style="float: right;">
<div class="col-sm-12 col-md-3">
<div class="input-group date datetimepicker">
<input id="Min-Date" type="text" class="form-control" placeholder="Start Date" />
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
</div>
<span class="col-md-1 fa fa-minus text-center" style="margin-top: 1%;"></span>
<div class="col-sm-12 col-md-3">
<div class="input-group date datetimepicker">
<input id="Max-Date" type="text" class="form-control" placeholder="End Date" />
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
</div>
</div>
<table id="Test-Table" class="table table-striped">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.randomClass.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.ReportDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Attachment)
</th>
<th></th>
</tr>
</thead>
<tfoot id="Table-Tfoot">
<tr>
<th>
@Html.DisplayNameFor(model => model.randomClass.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.ReportDate)
</th>
<th>
@Html.DisplayNameFor(model => model.Attachment)
</th>
<th></th>
</tr>
</tfoot>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.randomClass.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.ReportDate)
</td>
<td>
<a href="@Url.Content(item.Attachment)" target="_blank">@Path.GetFileName(item.Attachment)</a>
</td>
<td>
@Html.ActionLink("Edit", "Edit", "tblAttachments", new { id = item.ID }, null) |
@Html.ActionLink("Delete", "Delete", "tblAttachments", new { id = item.ID })
</td>
</tr>
}
</tbody>
</table>
我正在使用 jQuery DataTables进行搜索、分页和排序。这是我的 jQuery。
@section scripts{
<script>
$(document).ready(function () {
// https://datatables.net/examples/api/multi_filter.html
var total = $("#Table tfoot th").length;
$("#Table tfoot th").each(function (index) {
if (index !== total - 1) {
var title = $(this).text().trim();
$(this).html('<input type="text" class="form-control" placeholder="Search ' + title +'"/>');
}
});
var table = $("#Test-Table").DataTable({
"bFilter": false // hide searchbox
});
table.columns().every(function () {
var that = this;
$('input', this.footer()).on('keyup change',
function () {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
}
});
});
});
</script>
}
如您所见,我隐藏了 jQuery 数据表标准的初始搜索框。因为我希望能够按日期范围 进行过滤。
我研究过this ,但我不喜欢分页下拉列表上方的方框。我的也是如此。右上角的搜索框不见了。我希望两个 input取而代之。我怎样才能通过 CSS 做到这一点?
感谢任何帮助。
现在是这样的:
最佳答案
试试这个 plunker 演示 希望这能让你得到你的解决方案
http://plnkr.co/edit/mdeEYoZtnvpfHCdtSxDP?p=preview
$(function() {
var oTable = $('#datatable').DataTable({
"oLanguage": {
"sSearch": "Filter Data"
},
"iDisplayLength": -1,
"sPaginationType": "full_numbers",
});
$("#datepicker_from").datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: false,
"onSelect": function(date) {
minDateFilter = new Date(date).getTime();
oTable.fnDraw();
}
}).keyup(function() {
minDateFilter = new Date(this.value).getTime();
oTable.fnDraw();
});
$("#datepicker_to").datepicker({
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: false,
"onSelect": function(date) {
maxDateFilter = new Date(date).getTime();
oTable.fnDraw();
}
}).keyup(function() {
maxDateFilter = new Date(this.value).getTime();
oTable.fnDraw();
});
});
// Date range filter
minDateFilter = "";
maxDateFilter = "";
$.fn.dataTableExt.afnFiltering.push(
function(oSettings, aData, iDataIndex) {
if (typeof aData._date == 'undefined') {
aData._date = new Date(aData[0]).getTime();
}
if (minDateFilter && !isNaN(minDateFilter)) {
if (aData._date < minDateFilter) {
return false;
}
}
if (maxDateFilter && !isNaN(maxDateFilter)) {
if (aData._date > maxDateFilter) {
return false;
}
}
return true;
}
);
关于javascript - jQuery DataTables 日期范围样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45109048/
我有一大串格式化数据(例如JSON),我想使用Psychinruby同时保留格式转储到YAML。基本上,我希望JSON使用literalstyle出现在YAML中:---json:|{"page":1,"results":["item","another"],"total_pages":0}但是,当我使用YAML.dump时,它不使用文字样式。我得到这样的东西:---json:!"{\n\"page\":1,\n\"results\":[\n\"item\",\"another\"\n],\n\"total_pages\":0\n}\n"我如何告诉Psych以想要的样式转储标量?解
我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
请帮助我理解范围运算符...和..之间的区别,作为Ruby中使用的“触发器”。这是PragmaticProgrammersguidetoRuby中的一个示例:a=(11..20).collect{|i|(i%4==0)..(i%3==0)?i:nil}返回:[nil,12,nil,nil,nil,16,17,18,nil,20]还有:a=(11..20).collect{|i|(i%4==0)...(i%3==0)?i:nil}返回:[nil,12,13,14,15,16,17,18,nil,20] 最佳答案 触发器(又名f/f)是
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
我需要检查DateTime是否采用有效的ISO8601格式。喜欢:#iso8601?我检查了ruby是否有特定方法,但没有找到。目前我正在使用date.iso8601==date来检查这个。有什么好的方法吗?编辑解释我的环境,并改变问题的范围。因此,我的项目将使用jsapiFullCalendar,这就是我需要iso8601字符串格式的原因。我想知道更好或正确的方法是什么,以正确的格式将日期保存在数据库中,或者让ActiveRecord完成它们的工作并在我需要时间信息时对其进行操作。 最佳答案 我不太明白你的问题。我假设您想检查
我的日期格式如下:"%d-%m-%Y"(例如,今天的日期为07-09-2015),我想看看是不是在过去的七天内。谁能推荐一种方法? 最佳答案 你可以这样做:require"date"Date.today-7 关于ruby-检查日期是否在过去7天内,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/32438063/
我刚刚被困在这个问题上一段时间了。以这个基地为例:moduleTopclassTestendmoduleFooendend稍后,我可以通过这样做在Foo中定义扩展Test的类:moduleTopmoduleFooclassSomeTest但是,如果我尝试通过使用::指定模块来最小化缩进:moduleTop::FooclassFailure这失败了:NameError:uninitializedconstantTop::Foo::Test这是一个错误,还是仅仅是Ruby解析变量名的方式的逻辑结果? 最佳答案 Isthisabug,or
这个问题在这里已经有了答案:Railsformattingdate(4个答案)关闭4年前。我想格式化Time.Now函数以显示YYYY-MM-DDHH:MM:SS而不是:“2018-03-0909:47:19+0000”该函数需要放在时间中.现在功能。require‘roo’require‘roo-xls’require‘byebug’file_name=ARGV.first||“Template.xlsx”excel_file=Roo::Spreadsheet.open(“./#{file_name}“,extension::xlsx)xml=Nokogiri::XML::Build
我正在尝试解析一个CSV文件并使用SQL命令自动为其创建一个表。CSV中的第一行给出了列标题。但我需要推断每个列的类型。Ruby中是否有任何函数可以找到每个字段中内容的类型。例如,CSV行:"12012","Test","1233.22","12:21:22","10/10/2009"应该产生像这样的类型['integer','string','float','time','date']谢谢! 最佳答案 require'time'defto_something(str)if(num=Integer(str)rescueFloat(s