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

show/hideColumn performance issues

4 Answers 359 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 07 Oct 2016, 01:30 PM

Hi, I have implemented a second custom "column filter" to hide columns that start with a certain string based on user selection - 

Columns: Aaron, Chris, Ashley, Ryan

My selector has options 'A', 'C', 'R' with checkboxes, when one is unchecked, it will hide all cols that start with 'A', for example. 

 

My issue is in the performance of this method when the grid has many (50+) columns, taking multiple seconds to fulfill this loop: 

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

var columns - grid.columns

$.each(columns, function(i, el){

     

4 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 07 Oct 2016, 01:33 PM

apparently can't edit my post... anyway

$.each(columns, function(i, el){

     var CurrentColumn - columns[i];

     var currentTitle - currentColumn.title; 

     var colTitleText = jQuery(currentTitle).text();

     if(colTitleText.indexOf('A') == 0){

        grid.hideColumn(el)

}});

  

0
Accepted
Dimiter Topalov
Telerik team
answered on 11 Oct 2016, 07:36 AM
Hello Chris,

I can recommend setting the columns.hidden option, based on the described custom logic while looping through the columns, and finally use the setOptions() method, passing it the newly obtained columns configuration, e.g.:

var cols = grid.columns;
// loop through the columns and set the columns.hidden option
 
grid.setOptions({
  columns: cols
});

This will cause rerendering of the Grid only once, instead of each time the grid.hideColumn() method is called.

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Werdna
Top achievements
Rank 1
commented on 08 Sep 2021, 09:03 PM

This works for setting columns.hidden = true, but it doesn't work when trying to show columns that were initially hidden.  For example, if I set columns.hidden = false, the column does not display.  Any ideas?  

Thank you.

Nikolay
Telerik team
commented on 10 Sep 2021, 10:06 AM

Hi Werdna,

I just tested the approach of using the setOptions() method to show a hidden column and it seems to be working correctly:

let grid = $("#grid").data("kendoGrid");
var cols = grid.options.columns;
cols[0].hidden = false;
cols[1].hidden = true;
            
grid.setOptions({
    columns: cols
});

Here is a Dojo demo demonstrating this: https://dojo.telerik.com/eroyAQAt

Let me know if you have any questions.

Regards,

Nikolay

0
Sugendran
Top achievements
Rank 1
answered on 23 Nov 2016, 01:37 PM

This approach works, but we also need to update the column attributes - which is what the "setColumnVisibility" function in the kendo code does.

 

Would be great if there was a show/hide column method that took an array of columns so that the grid internals could deal with it and repaint only once.

0
Dimiter Topalov
Telerik team
answered on 24 Nov 2016, 11:25 AM
Hi Sugendran,

Please submit a feature request to our UserVoice portal:

http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback

It is closely monitored, and the most popular ideas are considered for implementation for future Kendo UI releases.

Our roadmap and priorities depend largely on the business value and customer demand for specific components and features.

However, I would like to bring your attention to an offering of ours that may be relevant and applicable to your needs - the Feature Acceleration program.

It allows a customer to negotiate certain functionality to be implemented on demand or sooner than our roadmap implies.

Let me know if you are interested in pursuing this option and I will put you in touch with our Professional Services team to discuss the exact specification, timeframe and pricing.

Regards,
Dimiter Topalov
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Sugendran
Top achievements
Rank 1
Share this question
or