如何知道Kendo Grid MVC中哪些列可见 [英] How to know what columns are visible whit Kendo Grid MVC

查看:129
本文介绍了如何知道Kendo Grid MVC中哪些列可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Kendo Grid的"x"列数,但是用户可以隐藏这些列,并且我需要知道可见的列才能仅导出这些列的数据,所以我访问了JS whit中的列

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");

,但它不仅返回可见列,还返回所有列. tankz

but it returns all columns not only the visibles. tankz

推荐答案

您可以使用以下方法获取列列表:

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

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

结果将为所有列对象的数组,该属性的属性名称为hidden: true,供用户隐藏列使用.就我而言,这就像跟随.因此,只需使用以下代码即可将可见列列表放入数组中.

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);
  }
});

隐藏列

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

可见列

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

希望这会有所帮助.

这篇关于如何知道Kendo Grid MVC中哪些列可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆