1
votes

I'm using a Kendo Grid. I have the ColumnMenu enabled so that the user can hide and show columns. I want to hide or disable my bulk action buttons my checkbox column is hidden. What's the best way to to determine if a column is hidden in the DataBound event?

1

1 Answers

3
votes

In the dataBound event, you can access the grid with

var grid = e.sender;

And the grid will have a columns collection.

grid.columns

If you dump that to the console, the columns that are not visible have a hidden property set to false. This is a dump of a 3 column grid's column property in the dataBound event.

[[object Object] {
  encoded: true,
  field: "name"
}, [object Object] {
  attributes: [object Object] {
    style: "display:none"
  },
  encoded: true,
  field: "age",
  footerAttributes: [object Object] {
    style: "display:none"
  },
  headerAttributes: [object Object] {
    style: "display:none"
  },
  hidden: true
}, [object Object] {
  encoded: true,
  field: "city"
}]

Here you can see the field for "age" has a property hidden: true. See sample http://jsbin.com/OxEToYA/1/edit