This question is locked. New answers and comments are not allowed.
Rui Martins
Top achievements
Rank 1
Rui Martins
asked on 20 Jul 2010, 12:03 PM
Hi,
how can i restore the default settings of my radGridView?
thanks,
Rui M.
how can i restore the default settings of my radGridView?
thanks,
Rui M.
14 Answers, 1 is accepted
0
Hello Rui Martins,
Could you please elaborate on the problem? What kind of setting would you like to restore to default state? When would you like the restore to take place?
Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Rui Martins
Top achievements
Rank 1
answered on 20 Jul 2010, 12:44 PM
hi Milan,
i had made a GrdiViewHeaderMenu where i can, for example, put my columns Visibility, not visibily and change the initial positions.
i made it based on your examples.
http://localhost:4107/Default.aspx#GridView/HeaderContextMenu and http://localhost:6519/Default.aspx#GridView/SaveLoadSettings
So now i want to give the user an option to restore the default settings (like add a menu item on the context menu)
thanks
Rui M.
i had made a GrdiViewHeaderMenu where i can, for example, put my columns Visibility, not visibily and change the initial positions.
i made it based on your examples.
http://localhost:4107/Default.aspx#GridView/HeaderContextMenu and http://localhost:6519/Default.aspx#GridView/SaveLoadSettings
So now i want to give the user an option to restore the default settings (like add a menu item on the context menu)
thanks
Rui M.
0
Rui Martins
Top achievements
Rank 1
answered on 20 Jul 2010, 02:36 PM
was not clear my explanation?
thanks for any advice or suggestion,
Rui M.
thanks for any advice or suggestion,
Rui M.
0
Rui Martins
Top achievements
Rank 1
answered on 20 Jul 2010, 03:43 PM
Anyone??? Any idea?
Rui M.
Rui M.
0
Rui Martins
Top achievements
Rank 1
answered on 21 Jul 2010, 09:22 AM
I don´t want to be boring but it is important for me that someone give me some guidance .
thanks,
Rui M.
thanks,
Rui M.
0
Hello Rui Martins,
Then, depending on your requirements and the exact settings you want to save, you may play around with the method Current_Exit(object sender, EventArgs e) and the Loaded event.
I am sending you a sample project illustrating the proposed solution.
Maya
the Telerik team
Following the basic idea shown in our online documentation for Save/Load GridView Layout, you can add additional properties of the column that need to be saved - in your case IsVisible and DisplayIndex. You may add them in the RadGridViewSettings class and then use them in the two methods SaveState() and LoadState(). For example:
public class ColumnSetting : PropertySetting
{
int displayIndex;
public int DisplayIndex
{
get
{
return displayIndex;
}
set
{
displayIndex = value;
}
}
}
public virtual void LoadState()
{
try
{
Settings.Reload();
}
catch
{
Settings.Reset();
}
if (this.grid != null)
{
grid.FrozenColumnCount = Settings.FrozenColumnCount;
if (Settings.ColumnSettings.Count > 0)
{
grid.AutoGenerateColumns = false;
grid.Columns.Clear();
foreach (ColumnSetting setting in Settings.ColumnSettings)
{
GridViewDataColumn column = new GridViewDataColumn();
column.UniqueName = setting.UniqueName;
column.DataMemberBinding = new Binding(setting.PropertyName);
column.Header = setting.Header;
column.IsVisible = setting.IsVisible;
column.DisplayIndex = setting.DisplayIndex;
....
}
Then, depending on your requirements and the exact settings you want to save, you may play around with the method Current_Exit(object sender, EventArgs e) and the Loaded event.
I am sending you a sample project illustrating the proposed solution.
Maya
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Rui Martins
Top achievements
Rank 1
answered on 21 Jul 2010, 03:40 PM
thanks Maya,
i understand what you said but i have another problem now.
I did a class GridViewHeaderMenu.cs where i create a ColumnHeader ContextMenu (not a button) so when i click in the option "Restore Default" the program goes to here in my GridViewHeaderMenu.cs
i understand what you said but i have another problem now.
I did a class GridViewHeaderMenu.cs where i create a ColumnHeader ContextMenu (not a button) so when i click in the option "Restore Default" the program goes to here in my GridViewHeaderMenu.cs
void
OnMenuOpened(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewHeaderCell cell = menu.GetClickedElement<GridViewHeaderCell>();
if
(cell !=
null
)
{
menu.Items.Clear();
RadMenuItem item =
new
RadMenuItem() { Header =
"Restore Default"
};
menu.Items.Add(item);
item =
new
RadMenuItem() { Header =
"Choose Columns:"
};
menu.Items.Add(item);
// create menu items
foreach
(GridViewColumn column
in
grid.Columns)
{
RadMenuItem subMenu =
new
RadMenuItem()
{
Header = column.Header,
IsCheckable =
true
,
IsChecked =
true
,
//SubmenuHeaderTemplateKey = null
};
// bind IsChecked menu item property to IsVisible column property
subMenu.SetBinding(RadMenuItem.IsCheckedProperty,
new
Binding(
"IsVisible"
) { Mode = BindingMode.TwoWay, Source = column });
item.Items.Add(subMenu);
}
}
else
{
menu.IsOpen =
false
;
}
}
void
OnMenuItemClick(
object
sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewHeaderCell cell = menu.GetClickedElement<GridViewHeaderCell>();
RadMenuItem clickedItem = ((Telerik.Windows.RadRoutedEventArgs)e).OriginalSource
as
RadMenuItem;
GridViewColumn column = cell.Column;
if
(clickedItem.Parent
is
RadMenuItem)
return
;
string
header = Convert.ToString(clickedItem.Header);
using
(grid.DeferRefresh())
{
Telerik.Windows.Data.SortDescriptor sd = (from d
in
grid.SortDescriptors
where d.Member == column.UniqueName
select d).FirstOrDefault();
if
(header.Contains(
"Restore Default"
))
{
//Here i wish to have the code that permit me to restore the original Grid...
}
...
So is there anyway to do this like that, pass an event handler for example?
or i have to create the ColumnHeader contextMenu on my Grid Xaml file? or a button like you did?
i did a columnHeaderContextMenu following your example here: http://localhost:6519/Default.aspx#GridView/HeaderContextMenu
thanks in advance,
Rui M.
0
Accepted
Hello Rui Martins,
Then in the OnMenuItemClick method implement the following logic in case the element of the ContextMenus is RestoreDefaultSettings:
And lastly, in the constructor of the MainPage:
Maya
the Telerik team
A possible approach in this case would be to define an Action in the GridViewHeaderMenu class:
public static Action OnRestoreSettingRequestedAction
{
get;
set;
}
Then in the OnMenuItemClick method implement the following logic in case the element of the ContextMenus is RestoreDefaultSettings:
void OnMenuItemClick(object sender, RoutedEventArgs e)
{
RadContextMenu menu = (RadContextMenu)sender;
GridViewHeaderCell cell = menu.GetClickedElement<
GridViewHeaderCell
>();
RadMenuItem clickedItem = ((RadRoutedEventArgs)e).OriginalSource as RadMenuItem;
GridViewColumn column = cell.Column;
if (clickedItem.Parent is RadMenuItem)
return;
string header = Convert.ToString(clickedItem.Header);
using (grid.DeferRefresh())
{
Telerik.Windows.Data.SortDescriptor sd = (from d in grid.SortDescriptors
where d.Member == column.UniqueName select d).FirstOrDefault();
if (header.Contains("Sort Ascending"))
{
if (sd != null)
{
grid.SortDescriptors.Remove(sd);
}
grid.SortDescriptors.Add(new Telerik.Windows.Data.SortDescriptor()
{
Member = column.UniqueName,
SortDirection = ListSortDirection.Ascending
});
}
......
}
if (header.Contains("Restore Default Settings"))
{
if (OnRestoreSettingRequestedAction != null)
{
OnRestoreSettingRequestedAction();
}
}
}
And lastly, in the constructor of the MainPage:
public MainPage()
{
InitializeComponent();
Application.Current.Exit += new EventHandler(Current_Exit);
this.playersGrid.Loaded += new RoutedEventHandler(playersGrid_Loaded);
GridViewHeaderMenu.OnRestoreSettingRequestedAction = () =>
{
primarySettings.LoadState();
};
}
Maya
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Rui Martins
Top achievements
Rank 1
answered on 23 Jul 2010, 11:39 AM
thanks Maya,
it´s work the context menu!!
now my problem it´s other.. it´s with the IsolatedStorageFile and the way to delete the file but i think it´s better to open another post with a better explanition...
thanks again,
Rui M
it´s work the context menu!!
now my problem it´s other.. it´s with the IsolatedStorageFile and the way to delete the file but i think it´s better to open another post with a better explanition...
thanks again,
Rui M
0
Pandit Prerna
Top achievements
Rank 1
answered on 27 Jul 2010, 08:52 PM
Hi,
Using this, it is possible for the grid to show default settings right away? I tried to rebind but that did not help.
Using this, it is possible for the grid to show default settings right away? I tried to rebind but that did not help.
0
Rui Martins
Top achievements
Rank 1
answered on 28 Jul 2010, 09:50 AM
Hi
Pandit Prerna
,
I have a post asking your issue but until now nobody give me a satisfactory answer, you can see it here:
http://www.telerik.com/community/forums/silverlight/gridview/reset-gridview-layout.aspx
so if you open another Thread with your question maybe it helps,
Let me know if you did it..
thanks,
Rui M.
I have a post asking your issue but until now nobody give me a satisfactory answer, you can see it here:
http://www.telerik.com/community/forums/silverlight/gridview/reset-gridview-layout.aspx
so if you open another Thread with your question maybe it helps,
Let me know if you did it..
thanks,
Rui M.
0
Hi,
Vlad
the Telerik team
Have you check the application attached to your other thread?
Regards,Vlad
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Rui Martins
Top achievements
Rank 1
answered on 28 Jul 2010, 10:15 AM
yes i have, i answer that now. Please can you read it?
thanks,
Rui M.
thanks,
Rui M.
0
Hello Rui Martins,
Please check the response on your other post - http://www.telerik.com/community/forums/silverlight/gridview/reset-gridview-layout.aspx
Kind regards,
Tsvyatko
the Telerik team
Please check the response on your other post - http://www.telerik.com/community/forums/silverlight/gridview/reset-gridview-layout.aspx
Kind regards,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items