Hi All,
Many of us struck with conditionally formatting Kendo Grid Columns. Here is the solution,
There are two ways you can do this,
- Using Template Function
- Using Client Template Function
You can use template function when there is no requirement for sorting of that column.
So I always suggest Client template.
Use the following way to do this,
.ClientTemplate(
"# if (DataField == null) { #" +
" " +
"# } else if (DataField == 0) { #" +
" " +
"# } else { #" +
"<div>#= kendo.toString(DataField , '<FormatString>') # </div>" +
"# } #"
);
"# if (DataField == null) { #" +
" " +
"# } else if (DataField == 0) { #" +
" " +
"# } else { #" +
"<div>#= kendo.toString(DataField , '<FormatString>') # </div>" +
"# } #"
);
Example:
.ClientTemplate(
"# if (empSalary == null) { #" +
" " +
"# } else if (empSalary == 0) { #" +
" " +
"# } else { #" +
"<div>#= kendo.toString(empSalary , 'c') # </div>" +
"# } #"
);
" " +
"# } else if (empSalary == 0) { #" +
" " +
"# } else { #" +
"<div>#= kendo.toString(empSalary , 'c') # </div>" +
"# } #"
);
Note:
Here I am giving Data field with preceding its object name.
No comments:
Post a Comment