Is it possible to remeber the interaction the user made with the grid? For example, if a user expands a column width, re-orders the columns I would like to save this information. When they next visit the page I would retrieve this information (stored in a DB) and redraw the grid as it was.
1) I would like to save on every time the user interacts with the grid, which implies I need to get the column widths of all columns and the order of all the columns.
2) If possible I would also like to do this with the grouping.
The main issues I have with both points is finding out the current settings of the gird. Any help with this would be much appreciated!
1) I would like to save on every time the user interacts with the grid, which implies I need to get the column widths of all columns and the order of all the columns.
2) If possible I would also like to do this with the grouping.
The main issues I have with both points is finding out the current settings of the gird. Any help with this would be much appreciated!
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 24 Jun 2010, 12:16 PM
Hello,
I hope the following online documentation will be of help in achieving the required.
Saving grid settings on a per user basis
-Shinu.
I hope the following online documentation will be of help in achieving the required.
Saving grid settings on a per user basis
-Shinu.
0
mabs
Top achievements
Rank 1
answered on 24 Jun 2010, 12:18 PM
Thank you, I should have read the guide in a little more depth!
0
mabs
Top achievements
Rank 1
answered on 24 Jun 2010, 03:40 PM
Thank you for the link, works very well.
However I have noticed a couple of problems. If I use the grouping part of the grid, then save the settings, if I remove the group so the grid returns to a normal grid, then load the settings back in, the page does not display correctly. The data loads in, however any columns previously hidded(done programatically) are displayed, also the styling for the grouping is wrong. Any ideas? If I click the load setting button for a second time it is then displayed correctly.
Another problem that also occurs is an error stating,
Specified argument was out of the range of valid values.
This appears if I have saved a grid with no grouping, I then select a column for grouping, load the previous settings (i.e. no grouping), which should remove the grouping.
Below is my code,
GridSettingsPersister is the class provided in the demos.
Any help would be mch appreciated!
However I have noticed a couple of problems. If I use the grouping part of the grid, then save the settings, if I remove the group so the grid returns to a normal grid, then load the settings back in, the page does not display correctly. The data loads in, however any columns previously hidded(done programatically) are displayed, also the styling for the grouping is wrong. Any ideas? If I click the load setting button for a second time it is then displayed correctly.
Another problem that also occurs is an error stating,
Specified argument was out of the range of valid values.
Parameter
name: index
This appears if I have saved a grid with no grouping, I then select a column for grouping, load the previous settings (i.e. no grouping), which should remove the grouping.
Below is my code,
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="Both" ShowGroupPanel="True" PageSize="15" AllowSorting="true" AllowPaging="true" AutoGenerateColumns="false"> |
<MasterTableView DataKeyNames="ROWCLICK"> |
</MasterTableView> |
<ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True" EnablePostBackOnRowClick="true" > |
<Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True" |
ResizeGridOnColumnResize="False"></Resizing> |
</ClientSettings> |
</telerik:RadGrid> |
Public Sub standardGrid(ByVal dt As DataTable) |
Dim boundColumn As GridBoundColumn |
If Not IsPostBack Then |
For Each column As DataColumn In dt.Columns |
If column.ColumnName.ToString() <> "ROWCLICK" Then |
boundColumn = New GridBoundColumn |
RadGrid1.MasterTableView.Columns.Add(boundColumn) |
boundColumn.DataField = column.ColumnName |
boundColumn.HeaderText = column.ColumnName.Replace("_", " ") |
Else |
boundColumn = New GridBoundColumn |
RadGrid1.MasterTableView.Columns.Add(boundColumn) |
boundColumn.DataField = column.ColumnName |
boundColumn.HeaderText = column.ColumnName |
boundColumn.Visible = False |
End If |
Next |
End If |
RadGrid1.DataSource = dt |
RadGrid1.DataBind() |
End Sub |
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
If e.CommandName = "RowClick" AndAlso TypeOf e.Item Is GridDataItem Then |
e.Item.Selected = True |
Dim strTemp As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ROWCLICK") |
RadGrid1.Controls.Add(New LiteralControl(String.Format("<span style='color:red'>{0}</span>", strTemp))) |
End If |
End Sub |
Protected Sub btn_save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_save.Click |
Dim SavePersister As New GridSettingsPersister(RadGrid1) |
Session("settings") = SavePersister.SaveSettings() |
End Sub |
Protected Sub btn_load_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_load.Click |
If Not Session("settings") = Nothing Then |
Dim settings As String = DirectCast(Session("settings"), String) |
Dim LoadPersister As New GridSettingsPersister(RadGrid1) |
LoadPersister.LoadSettings(settings) |
End If |
End Sub |
GridSettingsPersister is the class provided in the demos.
Any help would be mch appreciated!
0
Hi Russell,
I do not seem to be able to reproduce these issues you are describing. Attaching a sample project that demonstrates the full functionality of the GridSettingsPersister. Can you try to reproduce these issues in the sample project and let me know how I can do it too?
Greetings,
Veli
the Telerik team
I do not seem to be able to reproduce these issues you are describing. Attaching a sample project that demonstrates the full functionality of the GridSettingsPersister. Can you try to reproduce these issues in the sample project and let me know how I can do it too?
Greetings,
Veli
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