Reputation: 1151
I would like to hide those columns (that contain integer values) in my Kendo Grid in which all cells contain '0' values. Is the solution for that easy?
Upvotes: 5
Views: 6135
Reputation: 30661
You can hide a column via the hideColumn method. You can get the data to which the grid is bound to using the data method of the data source. Then traverse it to find if all records contain zeros. Here is a quick example:
var grid = $("#grid").data("kendoGrid");
var data = grid.dataSource.data();
var allZeroes = true;
for (var i = 0; i < data.length; i++) {
// say the name of the field to which the column is bound is "foo"
if (data[i].foo != 0) {
allZeroes = false;
break;
}
}
if (allZeroes) {
grid.hideColumn("foo");
}
Upvotes: 8