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

Sort disabled after heading text localized

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 18 Mar 2009, 11:42 PM
I am using using the ItemCreated event handler to change to column heading based on a specified language code.  The default is english and the english headings are coded in the grid definition.  I use the following code to set the text.  

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
        If TypeOf e.Item Is GridHeaderItem Then
            Dim headerItem As GridHeaderItem = CType(e.Item, GridHeaderItem)
            If lstLanguage.Text <> "en" Then
                Dim m As New Misc()
                Dim strText As String = m.GetText(Session("strDataConnectString"), 16, lstLanguage.Text)
                headerItem("UserName").Text = strText
                strText = m.GetText(Session("strDataConnectString"), 17, lstLanguage.Text)
                headerItem("Subject").Text = strText
                strText = m.GetText(Session("strDataConnectString"), 18, lstLanguage.Text)
                headerItem("UpdateDateTime").Text = strText
            End If
        End If
    End Sub

My problem is that once the heading text is changed, sorting is no longer active for those columns.  Only if the headers are in english (the default) can I sort.  I have searched for 2 hours trying to find posts regarding this and could not find any.  Thanks in advance for your help.

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 23 Mar 2009, 12:41 PM
Hello Matt ,

To make sure the functionality is not broken, please get a reference to the LinkButton control nested in the cell, and alter its text, rather than altering the text of the cell.
Give this suggestion a try and let me know how it goes.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Matthew Schneider
Top achievements
Rank 2
answered on 23 Mar 2009, 10:30 PM
Thanks Yavor.  I changed my code a follows and that fixed it. 

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
        If TypeOf e.Item Is GridHeaderItem Then
            Dim headerItem As GridHeaderItem = CType(e.Item, GridHeaderItem)
            If Session("strLang") <> "en" Then
                Dim m As New Misc()
                Dim strText As String = m.GetText(Session("strDataConnectString"), 16, Session("strLang"))
                Dim button As LinkButton = headerItem("UserName").Controls(0)
                button.Text = strText
                strText = m.GetText(Session("strDataConnectString"), 17, Session("strLang"))
                button = headerItem("Subject").Controls(0)
                button.Text = strText
                strText = m.GetText(Session("strDataConnectString"), 18, Session("strLang"))
                button = headerItem("UpdateDateTime").Controls(0)
                button.Text = strText
            End If
        End If
    End Sub

 

Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Matthew Schneider
Top achievements
Rank 2
Share this question
or