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

Filters customization

10 Answers 180 Views
GridView
This is a migrated thread and some comments may be shown as answers.
anouar b
Top achievements
Rank 1
anouar b asked on 03 Aug 2009, 11:25 AM
Hello,

Well i want to add new filters in my gridView ( on right clicking on a cell, i want to add more filter to the filters already present).
How can i proceed?

Thanks in advance.

10 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 03 Aug 2009, 12:58 PM
Hi anouar b,

Currently it isn't possible to insert additional filters inside the filtering menu. However, this is an interesting feature and we have it in mind. We will consider implementing it in one of our upcoming releases. Please, don't hesitate to write us back if you have other questions.

All the best,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
anouar b
Top achievements
Rank 1
answered on 03 Aug 2009, 01:20 PM
Hello,

So, can i add my own contextuel menu of filtering and call the existing filters inside my filter menu?
How can i create a customized contextuel menu related to an item in the gridView?


Thanks in advance
0
Jack
Telerik team
answered on 04 Aug 2009, 11:42 AM
Hi anouar,

Yes, you can customize the context menu in RadGridView. This includes the filtering menu. However, you can't add custom filter that use the data entered in the filtering cell. We will consider adding such API in a future version of RadGridView.

You should handle ContextMenuOpening event to add a custom item in the filtering menu. Here is a sample:

void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) 
    if (e.ContextMenuProvider == null
    { 
        e.ContextMenu.Items.Add(new RadMenuItem("Custom filter")); 
    } 

I hope this helps. Should you have any further questions, feel free to ask.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
anouar b
Top achievements
Rank 1
answered on 05 Aug 2009, 03:50 PM
Hello,

Thanks for your answer.
Now, my goal is to be able to call telerik filtering functions from my own buttons in the contextual menu.

Do you think it's possible?

thanks in advance
Anouar
0
Jack
Telerik team
answered on 06 Aug 2009, 11:45 AM
Hello anouar b,

Yes, this is possible. However you can call only the existing functions. You can't create your own. You should create a new filter expression and set it to the desired column. Here is a sample:

void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) 
    if (e.ContextMenuProvider == null
    { 
        RadMenuItem item = new RadMenuItem("new item"); 
        item.Click +=new EventHandler(item_Click); 
        e.ContextMenu.Items.Add(item); 
    } 
 
void item_Click(object sender, EventArgs e) 
    GridFilterCellElement cell = this.radGridView1.CurrentCell as GridFilterCellElement; 
    if (cell != null
    { 
        GridViewDataColumn dataColumn = cell.ColumnInfo as GridViewDataColumn; 
        object value = cell.Value; 
        FilterExpression filter = new FilterExpression(dataColumn.UniqueName); 
        filter.Predicates.Add(new FilterPredicate(FilterExpression.BinaryOperation.AND, GridKnownFunction.EndsWith, "@FilterEditor1")); 
        filter.Parameters.Add(new ParameterValuePair("@FilterEditor1", value)); 
        dataColumn.Filter = filter; 
    } 

If you need further assistance, don't hesitate to write back.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
anouar b
Top achievements
Rank 1
answered on 06 Aug 2009, 12:34 PM
Hello,

Thank you for your response.
Well, i have created the filter but my problem is how can i make two filters for the same column.
For exemple, i want to retrieve records which had the two conditions and in the same filter. (contain "client1", ou se termine par "t2))

 

FilterExpression filter = new FilterExpression(); 
filter.Predicates.Add(FilterExpression.BinaryOperation.AND,GridKnownFunction.Contains , 
GridFilterCellElement.ParameterName); 
filter.Predicates.Add(F
ilterExpression.BinaryOperation.OR, GridKnownFunction.EndsWith, 
GridFilterCellElement.ParameterName);
this.radGridView2.Columns[CurrentCellColumn].Filter = filter;
this.radGridView2.Columns[CurrentCellColumn].Filter = filter;
filter.Parameters.Add(GridFilterCellElement.ParameterName,"client1");
filter.Parameters.Add(
GridFilterCellElement.ParameterName,"t2");
  
this.radGridView2.Columns[CurrentCellColumn].Filter = filter;

But it dont works?

Thanks in advance.

 

 

 

0
anouar b
Top achievements
Rank 1
answered on 06 Aug 2009, 02:25 PM
In fact i want to do such the Custom Filter Dialog in demo examples.
0
Jack
Telerik team
answered on 07 Aug 2009, 08:23 AM
Hi anouar,

I understand. You should change a little your code. Use ParameterName2 as your second parameter and set the Filter property only once. Here is the modified code:

FilterExpression filter = new FilterExpression(); 
filter.Predicates.Add(FilterExpression.BinaryOperation.AND, GridKnownFunction.Contains, 
GridFilterCellElement.ParameterName); 
filter.Predicates.Add(FilterExpression.BinaryOperation.OR, GridKnownFunction.EndsWith, 
GridFilterCellElement.ParameterName2); 
filter.Parameters.Add(GridFilterCellElement.ParameterName, "client1"); 
filter.Parameters.Add(GridFilterCellElement.ParameterName2, "t2");             
this.radGridView1.Columns["Name"].Filter = filter; 

If you have any questions, please let me know.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erik
Top achievements
Rank 1
answered on 27 Jun 2016, 08:52 PM

Hi there,

I am trying to achieve what I thought would have been quite easy, but it is turning out to be quite the opposite.  I have a RadGridView that I have enabled filtering for.  I have also set the visibility of both the filter text (like "contains", "equals", etc...) and the filter button to "Collapsed".  That has given me a filter box that is just plain old grey, or whatever that color is.  When I click on one of the filter cells, the textbox editor appears. 

What I am looking to do is to have that textbox editor (or sometimes it is a spinner if it is a numeric column) just show all the time.  That is it.  I don't want to have to focus within the cell in order for the editor to show, I just want it there all the time.  I want it to be very clear to the user that the top cell is a filtering textbox, or spinner, whatever, that they can use to filter the data. 

Please advice if you have a way for me to do this.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jun 2016, 09:53 AM
Hello Erik,

Thank you for writing. 

Due to performance considerations, RadGridView is designed to use editing mechanism. A single cell can be in edit mode at a time. You can indicate the editor type without the necessity to have a text box in each filter cell. A sample code snippet is demonstrated in the following KnowledgeBase article: http://www.telerik.com/support/kb/winforms/gridview/details/indicate-the-editor-type-in-radgridview-columns

You can use a similar approach for the GridFilterCellElement to achieve your requirement. 

Alternatively, you can use a custom cell: a derivative of GridFilterCellElement. However, note that RadTextBoxElement hosts the MS TextBox. Using controls in grid cells may slow down the scrolling and will cause visual glitches as they do not support clipping. A better option would be using the editor indication as suggested above.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
anouar b
Top achievements
Rank 1
Answers by
Jack
Telerik team
anouar b
Top achievements
Rank 1
Erik
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or