Javascript 剑道ui网格匹配模式:行
我正在使用过滤列模式:网格中的行。对于我的数字列,菜单如下所示 我需要的是此列中的一个过滤器,作为菜单模式中使用的过滤器 这是我代码的一部分Javascript 剑道ui网格匹配模式:行,javascript,jquery,kendo-ui,kendo-grid,Javascript,Jquery,Kendo Ui,Kendo Grid,我正在使用过滤列模式:网格中的行。对于我的数字列,菜单如下所示 我需要的是此列中的一个过滤器,作为菜单模式中使用的过滤器 这是我代码的一部分 schema: { data: "results", total: "total", model: { id: "accountingTransactionKe
schema: {
data: "results",
total: "total",
model: {
id: "accountingTransactionKey",
fields: {
accountingTransactionKey: { editable: false, nullable: false },
date: { editable: false, nullable: false },
organization: { editable: false, nullable: false },
accountDebit: { editable: false, nullable: true },
costArticleUsed: { editable: false, nullable: true },
accountCredit: { editable: false, nullable: true },
isIntraGroupPartnerOrganization: { editable: false, nullable: true, type: "number" },
currency: { editable: false, nullable: true },
sum: { editable: false, nullable: true, type: "number"},...
...{
field: "sum",
title: "Сумма",
width: "150px",
//format: "{0:n2}",
locked: true,
filterable:
{
multi: true,
cell:
{
operator: "eq",
suggestionOperator: "eq",
showOperators: true
}
},
template: function (dataItem) { return numberWithSpaces(dataItem.sum.toFixed(2)) },
footerTemplate: "<b>" +"#: numberWithSpaces(sum.toFixed(2)) #"+"</b>"
},
模式:{
数据:“结果”,
总计:“总计”,
型号:{
id:“accountingTransactionKey”,
字段:{
accountingTransactionKey:{editable:false,nullable:false},
日期:{可编辑:false,可空:false},
组织:{可编辑:false,可空:false},
accountDebit:{可编辑:false,可空:true},
costArticleUsed:{editable:false,nullable:true},
accountCredit:{可编辑:false,可空:true},
isIntraGroupPartnerOrganization:{可编辑:false,可空:true,键入:“number”},
货币:{可编辑:false,可空:true},
求和:{可编辑:false,可空:true,键入:“number”},。。。
...{
字段:“总和”,
标题:“СаМа”,
宽度:“150px”,
//格式:“{0:n2}”,
是的,
可过滤:
{
多:是的,
单元格:
{
操作员:“eq”,
建议操作员:“eq”,
主持人:是的
}
},
模板:函数(dataItem){returnnumberWithspaces(dataItem.sum.toFixed(2))},
页脚模板:“+”#:带空格的数字(sum.toFixed(2))#“+”
},
我的要求有解决办法吗
谢谢我尝试了以下脚本,它使用属性为我提供了一个范围过滤器
$(文档).ready(函数(){
var griddata=createRandomData(50);
$(“#网格”).kendoGrid({
数据源:{
数据:网格数据,
模式:{
型号:{
字段:{
城市:{type:“string”},
标题:{type:“string”},
生日:{type:“date”},
年龄:{type:“number”}
}
}
},
页面大小:15
},
身高:550,
可滚动:对,
可过滤:{
额外:错,
操作员:{
字符串:{
startswith:“以开始”,
情商:“等于”,
neq:“不等于”
}
}
},
pageable:对,
栏目:[
{
标题:“姓名”,
宽度:160,
可过滤:false,
模板:“#=姓氏”
},
{
字段:“城市”,
宽度:130,
可过滤:false,
},
{
字段:“标题”,
可过滤:false,
},
{
字段:“生日”,
标题:“出生日期”,
格式:“{0:MM/dd/yyyy HH:MM tt}”,
可过滤:false,
},
{
字段:“年龄”,
宽度:100,
可过滤:
{
额外:对
}
}
]
});
});
如果要创建一个
列:[
{
字段:“年龄”,
可过滤:{
单元格:{template:betweenAgeFilter}
}
}
]
函数betweenAgeFilter(args){
var filterCell=args.element.parents(“.k-filterCell”);
filterCell.empty();
html('From:To:');
$(“#startAge”).kendonumeric文本框({
更改:功能(e){
var startAge=e.sender.value();
var endAge=$(“#endAge”).data(“kendoNumericTextBox”).value();
var数据源=$(“#网格”).data(“kendoGrid”).dataSource;
if(开始和结束){
var filter={logic:“and”,filters:[]};
filter.filters.push({field:“Age”,operator:“gte”,value:startAge});
<script>
$(document).ready(function() {
var griddata = createRandomData(50);
$("#grid").kendoGrid({
dataSource: {
data: griddata,
schema: {
model: {
fields: {
City: { type: "string" },
Title: { type: "string" },
BirthDate: { type: "date" },
Age: { type: "number" }
}
}
},
pageSize: 15
},
height: 550,
scrollable: true,
filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
}
},
pageable: true,
columns: [
{
title: "Name",
width: 160,
filterable: false,
template: "#=FirstName# #=LastName#"
},
{
field: "City",
width: 130,
filterable: false,
},
{
field: "Title",
filterable: false,
},
{
field: "BirthDate",
title: "Birth Date",
format: "{0:MM/dd/yyyy HH:mm tt}",
filterable: false,
},
{
field: "Age",
width: 100,
filterable:
{
extra: true
}
}
]
});
});
</script>
columns: [
{
field: "Age",
filterable: {
cell: { template: betweenAgeFilter }
}
}
]
function betweenAgeFilter(args) {
var filterCell = args.element.parents(".k-filtercell");
filterCell.empty();
filterCell.html('<span style="justify-content:center;"> <span>From:</span><input id="startAge"/><span>To:</span><input id="endAge"/></span>');
$("#startAge").kendoNumericTextBox({
change: function (e) {
var startAge = e.sender.value();
var endAge = $("#endAge").data("kendoNumericTextBox").value();
var dataSource = $("#grid").data("kendoGrid").dataSource;
if (startAge & endAge) {
var filter = { logic: "and", filters: [] };
filter.filters.push({ field: "Age", operator: "gte", value: startAge });
filter.filters.push({ field: "Age", operator: "lte", value: endAge });
dataSource.filter(filter);
}
}
});
$("#endAge").kendoNumericTextBox({
change: function (e) {
var startAge = $("#startAge").data("kendoNumericTextBox").value();
var endAge = e.sender.value();
var dataSource = $("#grid").data("kendoGrid").dataSource;
if (startAge & endAge) {
var filter = { logic: "and", filters: [] };
filter.filters.push({ field: "Age", operator: "gte", value: startAge });
filter.filters.push({ field: "Age", operator: "lte", value: endAge });
dataSource.filter(filter);
}
}
});
}