Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / Restore column position in data grid

Restore column position in data grid

New Discussion
Dom Nonymous
Dom Nonymous asked on Aug 5, 2020 1:14 PM

Hi,

I have a data grid with movable, sortable, pinnabe and hideable columns. I am working on a reset functionality for the grid, which resets every changes back to the default settings. Resetting for everything except column position seems pretty easy. Is there an option to restore the columns positions to its default, after they have been moved?

Sign In to post a reply

Replies

  • 0
    Martin Evtimov
    Martin Evtimov answered on Jul 30, 2020 1:00 PM

    Hello Dom,

    Thank you for contacting Infragistics Community!

    I believe you will find the following sample I have prepared for you very helpful in order to understand how to reset the initial columns order. As you can observe in order to achieve that I save the initial grid state in the ngAfterViewInit lifecycle hook and when the user clicks the button I reset the state. Please keep in mind, as stated in the Limitations section our Grid State Persistence topic, that getState method uses JSON.stringify() method to convert the original objects to a JSON string. However, this does not support functions, that’s why the [IgxGridState] directive will ignore the columns formatterfilterssummariessortStrategycellClassescellStyles, cellTemplates and headerTemplates properties. It is up to the developer to keep track and restore those on application level, which is out of the scope of Infragistics Support. 

    As you can observe, I have demonstrated a possible way of tracking and restoring the cell and header templates of the columns as well.

    If this sample is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me for further investigation.

    Looking forward to hearing from you.

    Best Regards,
    Martin Evtimov
    Entry Level Software Developer
    Infragistics, Inc.

    • 0
      Dom Nonymous
      Dom Nonymous answered on Aug 4, 2020 2:58 PM

      Thanks for your answer, that was exactly what I was looking for!

      • 0
        Martin Evtimov
        Martin Evtimov answered on Aug 5, 2020 1:14 PM

        Hello Dom,

        I’m glad that you find the provided information helpful.

        Best Regards,
        Martin Evtimov
        Entry Level Software Developer
        Infragistics, Inc.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Dom Nonymous
Favorites
0
Replies
3
Created On
Aug 05, 2020
Last Post
5 years, 7 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Aug 5, 2020 1:14 PM

Last activity on

Aug 5, 2020 1:14 PM