This is a migrated thread and some comments may be shown as answers.

visible columns json

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pankaj
Top achievements
Rank 1
Pankaj asked on 19 Oct 2016, 06:29 AM

Hi,

I have a requirement where i want only visible columns json data send to server. This is so because user will have ability to hide columns client side. Requirement is create excel at server side with only visible columns.

Regards,

Pankaj

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 20 Oct 2016, 02:35 PM
Hello Pankaj,

If you are using the client side export, it will work out of the box as shown here:
http://demos.telerik.com/kendo-ui/grid/excel-export

If you are using this method for server side export:
https://github.com/telerik/kendo-examples-asp-net-mvc/blob/master/grid-export-to-excel/KendoGridExportExcelMvc/Scripts/kendoExcelGrid.js#L42-L45
You may just loop the columns and serialize only the visible one. See the highlighted part of the code in the link above.
var visibleColumns = [];
jQuery.each(columns, function (index) {
  if(!this.hidden) {
    visibleColumns.push(this);
  }
});

It is pretty much the same for the dpl example:
https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/grid-dpl-integration/GridExcelSpreadProcessing/Views/Home/Index.cshtml#L40-L45

Regards,
Vasil
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
Grid
Asked by
Pankaj
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or