10 Answers, 1 is accepted
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.
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
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.
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
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.
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(FilterExpression.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.
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.
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.
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