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