剑道UI-网格/过滤器菜单自定义之间的2个日期



我正在使用一些Kendo UI网格,并且一直在使用可用的过滤选项,它们工作得很好。有人知道是否有方法为列进行日期范围筛选吗?我能得到的最接近的东西是>=和<=过滤器类型。但我真的需要能够在两次约会之间进行筛选。

有人知道是否有办法做到这一点吗?

感谢

我将与您分享关于列的日期范围筛选器的链接。。

http://dojo.telerik.com/@佩绍/UMIw/3

我希望你喜欢。。那就别忘了投票。。

您基本上需要为DataSource定义一个筛选器,然后调用filter方法。

具体操作如下:

// Get from date in this case we read it from an input DatePicker
var from = $("#from").data("kendoDatePicker").value()
// Get to date in this case we read it from an input DatePicker
var to = $("#to").data("kendoDatePicker").value()
// Create a filters condition. By default, the conditions are "and" but they might also
// be "or"
var filters = [
    {field: "BirthDate", operator: "gte", value: from},
    {field: "BirthDate", operator: "lte", value: to}
];
// Set the filtering condition to our grid dataSource
grid.dataSource.filter(filter);

你可以在这里看到它在运行:http://jsfiddle.net/OnaBai/f19k0vrt/3/

如果要永久显示日期,也可以在"网格"工具栏中定义日期的输入字段。

定义模板:

<script id="dates-template" type="text/kendo-tmpl">
    From: <input id="from" style="width: 120px"/> 
    To: <input id="to" style="width: 120px"/>
    <button id="filter" class="k-button">Filter</button>
</script>

将上面定义的工具栏模板添加到网格初始化中:

var grid = $("#grid").kendoGrid({
    toolbar   : [
        { template: kendo.template($("#dates-template").html()) }
    ],
    dataSource: ds,

你可以在这里看到它在运行:http://jsfiddle.net/OnaBai/f19k0vrt/4/

最新更新