Search code examples
reactjsreact-hooksdevextreme

Column resizing fix even after refreshing page


I have been working with DevExtreme REACTIVE for table.

One of its feature is column resizing which is working perfectly fine. But after refreshing the page it restores back to normal width.

Column resizing module

I want to for the width to remain same as what we have selected like in excel where once the width of column is set it remains same until we manually change the width again.

I have been looking for solution, but I was unable to find any solution regarding it.

How can we set the width value such that it remain same throughout?

Let me know if anyone needs any more details.

Link to their documentation


Solution

  • You should use a Session Storage for that function. Session storage is not changed/deleted after refreshing.

    LocalStorage.setItem('nameColumn', "name of the height variable")
    

    After that if you need to recover the height use this line.

    localStorage.getItem('nameColumn')
    

    If you have some Login/Logoff you should do that when you logoff

    localStorage.removeItem('nameColumn')
    

    OR

    localStorage.clear()