I have added custom functionality to my RadGrid to persist grid column visibility when user toggles column visibility from "Columns" context menu.
So whenever user comes back to that page, same columns are displayed as last time.
I am applying persisted settings in Grid prerender event by calling following function:
private void ApplyGridSettings()
{
var persistenceHelper = new PersistenceHelper();
var settings = persistenceHelper.GetGridPersistenceSettings(this.ClientID);
if (settings != null)
{
foreach (var columnSetting in settings.ColumnsSettings)
{
var column = this.Columns.FindByUniqueNameSafe(columnSetting.Column);
if (column != null)
{
column.Display = columnSetting.Visible;
}
}
}
}
Now I have added a header context menu "Reset Columns" to remove persisted settings and reset grid columns to default visibility.
I am calling following code on HeaderMenu click:
private void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
{
switch (e.Item.Text)
{
case "Reset Columns":
var persistenceHelper = new PersistenceHelper();
persistenceHelper.ResetGridColumns(this.ClientID);
this.MasterTableView.EnableColumnsViewState = false;
this.MasterTableView.Rebind();
break;
default:
break;
}
}
I thought after rebinding the grid will reset grid columns, but it is not working.
Can anyone please suggest how to reset grid columns visibility?
11 Answers, 1 is accepted
I recommend you examine the following online demo which demonstrates how you can easily save and restore RadGrid settings by using the Persistence Framework:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/persisting-grid-settings/defaultcs.aspx?product=grid
It also shows how you can save/restore grid columns visibility.
Regards,
PavlinaTelerik
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.
How does one reset the grid columns settings (display, visibility, width, etc)?
Indeed you are right that the grid does not reset columns visibility when Clear button is clicked. However, this is not related to the persistence framework but is rather demo configuration problem which will be fixed as soon as possible. I will get back to you once the example is updated. Please excuse us for the inconvenience caused.
Regards,
Pavlina
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.
I look forward to seeing how to best achieve having all the columns go back to their default state (display, visibility, width, orderindex, etc) as set in the ASPX file. The way I did it was by clearing the persistence and then completely reloading the page but I was hoping there would be a away via AJAX.
Curtis
If you can send us your exact scenario via a formal support ticket we would be able to get better understanding what you are trying to achive and if possible provide a solution via AJAX.
I am looking forward to your reply.
Regards,
Pavlina
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.
Hello,
I would like to know how to reset controls (RadGrid, combobox) to its default state - before applied persistence settings...
In the example mentioned above, the clear button still doesn't restore grid to default state :-(
Thank you
Vasssek
You can try the following approach to achieve this requirement:
http://www.telerik.com/forums/reset-the-grid-setting
I hope this will prove helpful.
Regards,
Eyup
Telerik by Progress
Hello,
thank you for that advice, but I'm afraid it's not on 100 % what I'm looking for. Let's say I hide some columns, then save grid state through persistance and now I want to show initial grid state (show previously hidden columns, etc.) - as if Page life cycle is in !Page.IsPostBack state. AFAIK - it can be done via Response.Redirect but I want to do it through AJAX...
Please help.
Regards
Vasssek
You can save the default state of RadGrid with another storage key and load the state using that default key once you need to reset the state to the default settings.
Hope this helps.
Regards,
Konstantin Dikov
Telerik by Progress
Hello,
thank you for your suggestion. To be honest, I did it this way. Store default settings to some SQL column and user change settings to another one. I just want to know if persistance manager didn't have such method to be called and than each control in page will be in state as when page is first time loaded.
Please consider to add this kind of method to some next build...
Thank you
Vasssek
The Persistence manager will save the state to a particular key it the current configuration of the controls and the requirement that you have could be achieved only manually, by saving the initial state to a specific key (for example, "default").
Kind Regards,
Konstantin Dikov
Telerik by Progress