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

column reorder event delay

5 Answers 325 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 11 Mar 2015, 01:36 PM
Hi, I'm trying to save grid on most user actions but the column reorder event seems to fire before the actual columns are reordered.  To accommodate this oddness I've added setTimeout around the saving of grid options.  Is this delay a known bug?


function saveUserAdministrationGridState(arg)
{
    if (isLocalStorageAvailable())
    {
        // column reordering firing delayed, so we must delay our saving of options
        setTimeout(function () {
            localStorage[customGridOptionsLocalStorageKey] = kendo.stringify(grid.getOptions());
        }, 5);
    }
}

5 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 13 Mar 2015, 09:29 AM
Hello Bob,

The observed behavior is by design and the correct column order is provided in the columnReorder event arguments. You can use those, or use setTimeout with your current implementation.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-columnReorder

It is theoretically possible to move the event triggering to occur after the DOM manipulation, so that it is easier for developers to store the Grid state, but this will represent a breaking change and we prefer to avoid this for the time being.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bob
Top achievements
Rank 1
answered on 13 Mar 2015, 01:04 PM
So do you think 5ms for setTimeout is safe?  It works locally, but if a user is on a machine with low processing power, I'm guessing it could take longer.

Also, do you have a working example of the column order from arguments being used to save grid state?
0
Accepted
Dimo
Telerik team
answered on 17 Mar 2015, 08:36 AM
Hello Bob,

Actually, the timeout period doesn't matter at all in this case, due to the so-called event loop concept - delayed scripts wait for the currently executed synchronous scripts (such as column DOM reordering) before being executed.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Narendra
Top achievements
Rank 1
answered on 28 Jun 2017, 07:03 PM

Hi Dimo,

I am using the grid.options.columns to get the list of columns. But after the I am not seeing the changed columns order in the grid.options.columns(Still showing the old grid column order). Is there any way that I can get the new column order?

Thanks

0
Dimo
Telerik team
answered on 29 Jun 2017, 10:19 AM
Hello Narendra,

grid.options.columns keeps the columns' initial state. For the current state, please use the dedicated and public API field:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#fields-columns

Regards,
Dimo
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Bob
Top achievements
Rank 1
Narendra
Top achievements
Rank 1
Share this question
or