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

Kendo Grid Column Width Persistence

2 Answers 288 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 20 Jun 2014, 02:41 PM
I am looking to apply my saved grid column width(s) back to the grid. 
I have been able to retrieve them successfully, but have not yet been able to restore them.
Would i apply these using a dataBound event? Haven't had any success. I would appreciate some guidance.

  columnResize: function (e) {
                            var grid = this;
                            var state = {};
                            grid.columns.every(function(c, i) {
                                state[c.field] = c.width;
                                return true;
                            });
                              //Save to browser localStorage
                            localStorage.setItem('gridColumnWidth', JSON.stringify(state));
                        },

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Jun 2014, 11:11 AM
Hello Michael,

Basically if you save the columns state in a cookie or on the server side and you later reload it, the width order and all options will be persisted. Same approach is used in this code library, you can get the idea from there:

http://www.telerik.com/support/code-library/save-grid-state-in-session-on-server-side

The JavaScript logic remains the same.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Michael
Top achievements
Rank 1
answered on 25 Jun 2014, 07:26 PM
Petur,

This helped me solve my problem. Thank you so much.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or