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

Column Chooser with postback

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jocelyn
Top achievements
Rank 1
Jocelyn asked on 28 Nov 2012, 07:17 PM
Hi,

I use your GridSettingsPersister.vb and save those settings in a DataBase. I don't save the settings using a "Save settings button" I do it in the Grid PreRender event on a PostBack:

VB
Public Sub tmpGrid_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim tmpGrid As RadGrid = sender
    Dim settingsType As GridSettingsType = GridSettingsType.ColumnSettings Or _
                                            GridSettingsType.Grouping Or _
                                            GridSettingsType.Paging Or _
                                            GridSettingsType.Sorting
    Dim persister As New GridSettingsPersister(tmpGrid, settingsType)
 
    If tmpGrid.Page.IsPostBack Then
        Dim param As String = persister.SaveSettings()
    Else
        Dim SQLGrille As LWebStatement = ExecuteSql("Select UCPR_NOAUTO, PARAM from USAGERCOLONNEPRESCRIPTEUR " & _
                                      " WHERE NOAUTOUSAGER = " & CurrentUser.NoCurrentUser & _
                                              " AND NOMPAGE = '" & tmpGrid.Page.ToString & "' " & _
                                              " AND NOMGRILLE = '" & tmpGrid.ID & "'")
        If SQLGrille.HasRecord Then
            persister.LoadSettings(SQLGrille.GetString("PARAM"))
            tmpGrid.Rebind()
        End If
    End If
End Sub

It works like a charm except for the Column chooser because it is client side. How can I force a PostBack when the user Show/Hide a column?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 03 Dec 2012, 10:13 AM
Hello,

 If you are using the header context menu of the grid the show / hide operation there works only on the client. If you need to perform a postback you will need to customize the header context menu as shown in the help topic by adding new custom items that fire a custom command from the client using the fireCommand method of the grid which can be handled on the server side and there you can show or hide the column and preserve the setting.

Greetings,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jocelyn
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or