How to know what columns are visible whit Kendo Grid MVC

独自空忆成欢 提交于 2019-12-11 07:55:37

问题


i have a Kendo Grid whit "x" number of columns, but the user can hide the columns and i need know what columns are visible to export data only for these columns, i access to the columns in JS whit

var columns = $("#grid").data("kedoGrid");

but it returns all columns not only the visibles. tankz


回答1:


You can just get the list of columns by using this:

var columns = $("#grid").data("kendoGrid").columns;

The result will be an array of all column objects which has a property name hidden: true for hidden columns by users. In my case it is like following. So simply you will be able to get the visible column list into an array using following code.

var visibleColumns = [];
jQuery.each(columns, function (index) {
  if(!this.hidden) {
    visibleColumns.push(this);
  }
});

Hidden Column

attributes: Object
encoded: true
field: "pb"
footerAttributes: Object
headerAttributes: Object
hidden: true
title: "Price / Book"
width: 120
__proto__: Object

Visible Column

encoded: true
field: "name"
title: "Company Name"
width: 120
__proto__: Object

Hope this will help.



来源:https://stackoverflow.com/questions/18494158/how-to-know-what-columns-are-visible-whit-kendo-grid-mvc

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