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

Hide the Match Case button in the filter popup?

4 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JC
Top achievements
Rank 1
JC asked on 29 Oct 2011, 12:12 AM
There is sample code in the docs for hiding the match case button here: 
http://www.telerik.com/help/silverlight/gridview-how-to-hide-match-case.html

It appears to be out of date as this code does not build.  I get the following error: 
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<System.Windows.Controls.Primitives.ToggleButton>'

For this line of code in the docs:
 ((StringFilterEditor) sender).ChildrenOfType<ToggleButton>()[0].Visibility = Visibility.Collapsed;

Any ideas how to accomplish this with the latest build of the gridview control?

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 31 Oct 2011, 07:34 AM
Hello Jc,

 
Please check this online help article for further info. 


Best wishes,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
JC
Top achievements
Rank 1
answered on 31 Oct 2011, 06:34 PM
Hello Vanya, as I indicated in my post that code does *NOT* compile. I get the error indicated in my first post.
0
Vanya Pavlova
Telerik team
answered on 03 Nov 2011, 10:14 AM
Hi Jc,

 
Please accept my apology for the omission! Indeed you are right. We have recently changed the ChildrenOfType extension method and you cannot use indexers. You should change the code in the following way and it would work as expected:

private void gridView_FieldFilterEditorCreated(object sender, Telerik.Windows.Controls.GridView.EditorCreatedEventArgs e)
      {
          var stringFilterEditor = e.Editor as StringFilterEditor;
          if (stringFilterEditor != null)
          {
              stringFilterEditor.Loaded += new RoutedEventHandler(stringFilterEditor_Loaded);
          }
      }
      void stringFilterEditor_Loaded(object sender, RoutedEventArgs e)
      {
          ((StringFilterEditor)sender).ChildrenOfType<ToggleButton>().First().Visibility = Visibility.Collapsed;
      }


We will update our online help article and the snippet will be changed correspondingly! 


Regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mohammad
Top achievements
Rank 1
answered on 29 Nov 2012, 12:01 PM
Hi,

I have used the above code and translated it to vb.net for an application I am working on. My translation is as follows:

Private Sub gridView_FieldFilterEditorCreated(sender As Object, e As Telerik.Windows.Controls.GridView.EditorCreatedEventArgs)
	Dim stringFilterEditor = TryCast(e.Editor, StringFilterEditor)
	If stringFilterEditor IsNot Nothing Then
		stringFilterEditor.Loaded += New RoutedEventHandler(AddressOf stringFilterEditor_Loaded)
	End If
End Sub
Private Sub stringFilterEditor_Loaded(sender As Object, e As RoutedEventArgs)
	DirectCast(sender, StringFilterEditor).ChildrenOfType(Of ToggleButton)().First().Visibility = Visibility.Collapsed
End Sub

This however does not work as stringFilterEditor.Loaded does not compile. Can you please tell me where I am going wrong with this?

Mo.
Tags
GridView
Asked by
JC
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
JC
Top achievements
Rank 1
Mohammad
Top achievements
Rank 1
Share this question
or