问题
if we apply if else condition in Kendo grid column then filterable not working for that particular column
{
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 #} #"
}
回答1:
Kendo Grid sorting and filtering functionality works based on the field
value not based on the template
value.
Here there is no field mapped to the column, so it is not working.
To resolve this issue: Pass the complianceStatus value from backend instead of writing template in grid.
Create a String
field in the object and set value to that field based on the above conditions and then map that field in the grid, template not required.
For example if you are using java as backend:
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 ;
}
And in grid column:
{ field: "complianceStatus", title: "Compliance Status", width: "180px" }
来源:https://stackoverflow.com/questions/56440189/filterable-is-not-working-for-grid-if-i-am-apply-if-else-condition-in-grid