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

Grid columns user preference

3 Answers 313 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murali
Top achievements
Rank 1
Murali asked on 28 Jul 2016, 08:27 PM
I would like to let user hide columns in the grid they don't want and order columns in the grid the way they want. Right now we have the feature to hide the column in the grid(through code) but user cannot do that. Is there a way to let the user hide the column with a cancel button so that I will save that column preference data in the database to hide that column for the user when he logs in the next time and also I would like to let the user order the columns in the grid by dragging and drop. Thanks

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Topalov
Telerik team
answered on 01 Aug 2016, 10:56 AM
Hi Murali,

You can set the Grid's reorderable option to true to allow column reordering:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-reorderable

As for allowing the user to hide/show columns, you can use the columnMenu option:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columnMenu

The following online demos illustrate the discussed functionalities:

http://demos.telerik.com/kendo-ui/grid/column-reordering

http://demos.telerik.com/kendo-ui/grid/column-menu

I hope this helps.

Regards,
Dimiter Topalov
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
0
Murali
Top achievements
Rank 1
answered on 16 Aug 2016, 01:57 PM

Hi Dimiter,

I see that we can order the columns, hide/show columns. Now I have a different question is there a predefined way to get the selected/unselected columns so that I will save those preferences for user and replicate the same when the user logs in next time.

Regards

Murali

0
Dimo
Telerik team
answered on 18 Aug 2016, 09:42 AM
Hi Murali,

In case you mean the selected/unselected columns in the column menu, then you can obtain the column visibility state from the Grid columns field:

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#fields-columns

Iterate the array of column objects and check if there is a hidden field with a true value for each of them.

You can also utilize the columnHide and columnShow events, if needed.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-columnHide
 
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-columnShow

Regards,
Dimo
Telerik by Progress
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Tags
Grid
Asked by
Murali
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Murali
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or