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

Save Column Reorder

1 Answer 569 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 04 Jun 2014, 04:50 PM
When a user changes the order of columns in a grid, I was able to capture the new column order, serialize it, and store it.
I just can't figure out how to bring that data back and re-apply it to the grid when the page reloads.

I used the "columReorder"  event to post a service call to store the results.
 columnReorder: function (e) {
                var that = this;
                setTimeout(function () {
                    SaveColsGrid1(kendo.stringify(that.columns));
                }, 5);
            },

I've tried a couple ways to bring in columns.
I tried binding to kindo grid "columns" property, but an external web service call doesn't come back in time before the grid renders.
Am I going about this correctly or is there a better way to take a serialized list of columns (that i've saved) and set the order when the grid loads?

Thanks,
Ben

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 06 Jun 2014, 08:29 AM
Hi Ben,

Generally, you have two options (given the you are using a server Grid wrapper):

1) Use the stored information server-side and produce a corresponding Grid declaration with appropriate column order.

Html.Kendo().Grid()
    .Columns(columns =>
    {
        foreach (var property in propertyArray)
        {
            columns.Bound(property.FieldName); // etc......
        }
    })


2) Use the stored information client-side and reorder the columns after Grid initialization via the widget API.

http://docs.telerik.com/kendo-ui/api/web/grid#methods-reorderColumn


A third option, which is possible when using a client-side Grid declaration is to generate a suitable columns configuration for the Grid initialization statement.

http://docs.telerik.com/kendo-ui/api/web/grid#configuration-columns

Regards,
Dimo
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or