如果我在网格中应用其他条件,则可过滤不适用于网格
filterable is not working for grid if i am apply if else condition in grid
如果我们在 Kendo 网格列中应用 if else 条件,则可过滤不适用于该特定列
{
field: " ", title: "Compliance Status", width: "180px",
template: "# if(WithinDueDt == 'Y'){# Completed on time #} else if(Ongoing == 'Y'){# Ongoing #} else if(CompletedbutDelayed == 'Y'){# Completed but Delayed #} else if(OngoingbutDelayed == 'Y'){# Ongoing but Delayed #} #"
}
Kendo 网格排序和过滤功能基于 field
值而不是基于 template
值。
这里没有映射到列的字段,所以它不起作用。
要解决此问题:从后端传递 complianceStatus 值,而不是在网格中编写模板。
在对象中创建一个String
字段并根据上述条件为该字段设置值,然后将该字段映射到网格中,不需要模板。
例如,如果您使用 java 作为后端:
private String complianceStatus;
private String getComplianceStatus(){
complianceStatus = "";
if(WithinDueDt == "Y"){ complianceStatus = "Completed on time" }
else if(Ongoing == "Y"){ complianceStatus = "Ongoing" }
else if(CompletedbutDelayed == "Y"){complianceStatus = "Completed but Delayed"}
else if(OngoingbutDelayed == "Y"){complianceStatus = "Ongoing but Delayed"}
return complianceStatus ;
}
在网格列中:
{ field: "complianceStatus", title: "Compliance Status", width: "180px" }
如果我们在 Kendo 网格列中应用 if else 条件,则可过滤不适用于该特定列
{
field: " ", title: "Compliance Status", width: "180px",
template: "# if(WithinDueDt == 'Y'){# Completed on time #} else if(Ongoing == 'Y'){# Ongoing #} else if(CompletedbutDelayed == 'Y'){# Completed but Delayed #} else if(OngoingbutDelayed == 'Y'){# Ongoing but Delayed #} #"
}
Kendo 网格排序和过滤功能基于 field
值而不是基于 template
值。
这里没有映射到列的字段,所以它不起作用。
要解决此问题:从后端传递 complianceStatus 值,而不是在网格中编写模板。
在对象中创建一个String
字段并根据上述条件为该字段设置值,然后将该字段映射到网格中,不需要模板。
例如,如果您使用 java 作为后端:
private String complianceStatus;
private String getComplianceStatus(){
complianceStatus = "";
if(WithinDueDt == "Y"){ complianceStatus = "Completed on time" }
else if(Ongoing == "Y"){ complianceStatus = "Ongoing" }
else if(CompletedbutDelayed == "Y"){complianceStatus = "Completed but Delayed"}
else if(OngoingbutDelayed == "Y"){complianceStatus = "Ongoing but Delayed"}
return complianceStatus ;
}
在网格列中:
{ field: "complianceStatus", title: "Compliance Status", width: "180px" }