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?
You showing/hiding columns in KendoUI Grid you should use showColumn and hideColumn and use as argument a number (the index of the column that you want to show/hide) or a string (the name of the field associated in that column). Example: var grid = $("#grid").
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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With