column reorder event delay

6 posts, 2 answers
  1. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 11 Mar 2015 Link to this post

    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);
        }
    }
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8474 posts

    Posted 13 Mar 2015 Link to this post

    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!
     
  3. Bob
    Bob avatar
    123 posts
    Member since:
    Sep 2012

    Posted 13 Mar 2015 in reply to Dimo Link to this post

    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?
  4. Answer
    Dimo
    Admin
    Dimo avatar
    8474 posts

    Posted 17 Mar 2015 Link to this post

    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!
     
  5. Narendra
    Narendra avatar
    7 posts
    Member since:
    May 2017

    Posted 28 Jun 2017 Link to this post

    Hi Dimo,

    I am using the grid.options.columns to get the list of columns. But after the columnReorder 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

  6. Dimo
    Admin
    Dimo avatar
    8474 posts

    Posted 29 Jun 2017 Link to this post

    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.
Back to Top