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

show and hide the filter menu options as per columns in radgrid

1 Answer 410 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 19 May 2014, 02:00 PM
Hi ,

  I have developed one telerik grid with filter options on every columns , here I have name column and date column and I need to show and hide the  filter menu options as per the column type for name column  need to hide between and Not Between options and  date  column need to show above two options  but my problem is when I hide the between option in name column it hided  and date column also this action is affected I need to show these two option in date column but not to show name column please help me to do filter menu show hide as per columns and I am using vb for server side code and aspx for design

below is my code for hide the filter menu option :

  Dim Menu As GridFilterMenu = grdAssessment.FilterMenu
        Dim menuItem As RadMenuItem
        For Each column As GridColumn In grdAssessment.MasterTableView.Columns

            If column.UniqueName = "Name" Then
                For Each menuItem In Menu.Items
                    If menuItem.Text = "StartsWith" Then
                        menuItem.Text = "Starts With"
                    ElseIf menuItem.Text = "GreaterThanOrEqualTo" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "DoesNotContain" Then
                        menuItem.Text = "DoesNot Contain"
                    ElseIf menuItem.Text = "GreaterThanOrEqualTo" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "GreaterThan" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "LessThan" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "LessThanOrEqualTo" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "EndsWith" Then
                        menuItem.Text = "Ends With"
                    ElseIf menuItem.Text = "NotEqualTo" Then
                        menuItem.Text = "Not Equal To"
                    ElseIf menuItem.Text = "Between" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "NotBetween" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "IsEmpty" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "NotIsEmpty" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "IsNull" Then
                        menuItem.Visible = False
                    ElseIf menuItem.Text = "NotIsNull" Then
                        menuItem.Visible = False
                    End If
                Next
            ElseIf column.UniqueName = "ProposedStartDate" Then
                For Each menuItem In Menu.Items
                    If menuItem.Text = "NotBetween" Then
                        menuItem.Visible = True
                        menuItem.Text = "Not Between"
                    ElseIf menuItem.Text = "NoFilter" Then
                        menuItem.Text = "No Filter"
                    ElseIf menuItem.Text = "Between" Then
                        menuItem.Visible = True
                    End If
                Next
            End If

        Next    





1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 22 May 2014, 05:37 AM
Hello Matthew,

In order to achieve your scenario you could follow the JavaScript approach shown in the article below. The idea is to subscribe to RadGrid FilterMenuShowing event and change the options dynamically. Note that a client-side JavaScript approach is required because the filter options are changed on the client and there is no way to customize the menu based on each column from the server because the changes will be overridden from the client.

Regards,
Antonio Stoilkov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Filter
Asked by
Matthew
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or