filterable is not working for grid if i am apply if else condition in grid

与世无争的帅哥 提交于 2019-12-25 01:14:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!