Filters customization

11 posts, 0 answers
  1. anouar b
    anouar b avatar
    13 posts
    Member since:
    Jul 2009

    Posted 03 Aug 2009 Link to this post

    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.
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 03 Aug 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. anouar b
    anouar b avatar
    13 posts
    Member since:
    Jul 2009

    Posted 03 Aug 2009 Link to this post

    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
  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 04 Aug 2009 Link to this post

    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.
  6. anouar b
    anouar b avatar
    13 posts
    Member since:
    Jul 2009

    Posted 05 Aug 2009 Link to this post

    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
  7. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 06 Aug 2009 Link to this post

    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.
  8. anouar b
    anouar b avatar
    13 posts
    Member since:
    Jul 2009

    Posted 06 Aug 2009 Link to this post

    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.

     

     

     

  9. anouar b
    anouar b avatar
    13 posts
    Member since:
    Jul 2009

    Posted 06 Aug 2009 Link to this post

    In fact i want to do such the Custom Filter Dialog in demo examples.
  10. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 07 Aug 2009 Link to this post

    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.
  11. Erik
    Erik avatar
    1 posts
    Member since:
    Feb 2016

    Posted 27 Jun Link to this post

    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.

  12. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 30 Jun Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready