I have a RadGrid that has several columns. (18 to be precise) though only 6 of these columns display by default. The rest are set to 'display=false'. I'm trying to make it show that when a user changes what columns are displayed that change is persisted through their experience using sessions so that if they navigate away and come back to the page it will retain the changes they made.
I am following the instructions provided: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx on the demo however I am having issues with modifying this so that it calls my SaveSettings method.
Is there a way to have it so that when the user hides or shows a column that it calls the SaveSettings method?
ASPX
Code Behind
I am following the instructions provided: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx on the demo however I am having issues with modifying this so that it calls my SaveSettings method.
Is there a way to have it so that when the user hides or shows a column that it calls the SaveSettings method?
ASPX
<
telerik:RadGrid
ID
=
"gvDash"
runat
=
"server"
GridLines
=
"None"
AutoGenerateColumns
=
"false"
DataSourceID
=
"dsDashboard"
PageSize
=
"15"
Width
=
"100%"
ShowStatusBar
=
"true"
AllowPaging
=
"true"
AllowSorting
=
"true"
>
<
MasterTableView
DataKeyNames
=
"FileID"
CommandItemDisplay
=
"Top"
AllowMultiColumnSorting
=
"true"
EnableHeaderContextMenu
=
"true"
EditMode
=
"PopUp"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowExportToWordButton
=
"true"
ShowExportToExcelButton
=
"true"
/>
<
NoRecordsTemplate
>
<
em
>No Records</
em
>
</
NoRecordsTemplate
>
<
AlternatingItemStyle
CssClass
=
"alt-row"
/>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"Options"
Groupable
=
"false"
AllowFiltering
=
"false"
HeaderText
=
"Options"
>
<
ItemTemplate
>
<
asp:HyperLink
ID
=
"EditLink"
runat
=
"server"
Text
=
"Edit"
></
asp:HyperLink
>
<
asp:LinkButton
ID
=
"btnView"
runat
=
"server"
Text
=
"View"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"FileNo"
DataField
=
"FileNo"
HeaderText
=
"File Number"
SortExpression
=
"FileNo"
Groupable
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"DisplayName"
DataField
=
"DisplayName"
HeaderText
=
"Vessel"
SortExpression
=
"DisplayName"
/>
<
telerik:GridBoundColumn
UniqueName
=
"VesselStatusName"
DataField
=
"VesselStatusName"
HeaderText
=
"Status"
SortExpression
=
"VesselStatusName"
/>
<
telerik:GridBoundColumn
UniqueName
=
"OfficeName"
DataField
=
"OfficeName"
HeaderText
=
"Office Location"
SortExpression
=
"OfficeName"
/>
<
telerik:GridCheckBoxColumn
UniqueName
=
"AddedToQB"
DataField
=
"AddedToQB"
HeaderText
=
"Vsl Added QB"
SortExpression
=
"AddedToQB"
/>
<
telerik:GridBoundColumn
UniqueName
=
"VesselSailed"
DataField
=
"VesselSailed"
HeaderText
=
"Sail Date"
SortExpression
=
"VesselSailed"
DataFormatString
=
"{0:M/d/yyyy HH:mm}"
/>
<
telerik:GridCheckBoxColumn
UniqueName
=
"SailDateQB"
DataField
=
"SailDateQB"
HeaderText
=
"Sail Date Added QB"
SortExpression
=
"SailDateQB"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CargoName"
DataField
=
"CargoName"
HeaderText
=
"Cargo"
SortExpression
=
"CargoName"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"PayingPrinci"
HeaderText
=
"Paying Principal"
GroupByExpression
=
"PayingPrinciName Group By PayingPrinciName"
SortExpression
=
"PayingPrinciName"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblPayingPrinci"
runat
=
"server"
Text='<%# Bind("PayingPrinciName") %>'></
asp:Label
>
<
br
/><
asp:Label
ID
=
"lblPayingPrinciAddress"
CssClass
=
"label-note"
runat
=
"server"
Text='<%# Bind("PayingPrinciAddress") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"PDAAmnt"
DataField
=
"PDAAmnt"
HeaderText
=
"PDA AMT"
SortExpression
=
"PDAAmnt"
DataFormatString
=
"{0:c}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"RECVDAmnt"
DataField
=
"RECVDAmnt"
HeaderText
=
"PDA AMT Rcvd"
SortExpression
=
"RECVDAmnt"
DataFormatString
=
"{0:c}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"PerformaDateRcvd"
DataField
=
"PerformaDateRcvd"
HeaderText
=
"PDA Date Rcvd"
SortExpression
=
"PerformaDateRcvd"
DataFormatString
=
"{0:M/d/yyyy}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CTMAmnt"
Display
=
"false"
DataField
=
"CTMAmnt"
HeaderText
=
"CTM AMT"
SortExpression
=
"CTMAmnt"
DataFormatString
=
"{0:c}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CTMAmntRcvd"
Display
=
"false"
DataField
=
"CTMAmntRcvd"
HeaderText
=
"CTM AMT Rcvd"
SortExpression
=
"RECVDAmnt"
DataFormatString
=
"{0:c}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"CTMAmntDate"
Display
=
"false"
DataField
=
"CTMAmntDate"
HeaderText
=
"CTM Date Rcvd"
SortExpression
=
"PerformaDateRcvd"
DataFormatString
=
"{0:M/d/yyyy}"
/>
<
telerik:GridBoundColumn
UniqueName
=
"PortName"
DataField
=
"PortName"
HeaderText
=
"Port"
SortExpression
=
"PortName"
/>
<
telerik:GridBoundColumn
UniqueName
=
"AccountingNotes"
Display
=
"false"
DataField
=
"AccountingNotes"
HeaderText
=
"Comments"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowColumnsReorder
=
"true"
AllowColumnHide
=
"true"
>
<
Resizing
AllowColumnResize
=
"true"
AllowResizeToFit
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
Code Behind
Private
Sub
LoadSettings()
If
Not
IsNothing(Session(
"Acc.Funds.GridSettings"
))
Then
Dim
LoadPersister
As
New
GridSettingsPersister(gvDash)
Dim
settings
As
String
=
DirectCast
(Session(
"Acc.Funds.GridSettings"
),
String
)
LoadPersister.LoadSettings(settings)
End
If
End
Sub
Private
Sub
SaveSettings()
Dim
SavePersister
As
New
GridSettingsPersister(gvDash)
Session(
"Acc.Funds.GridSettings"
) = SavePersister.SaveSettings()
End
Sub