Filter on "Contains" problem

10 posts, 0 answers
  1. Lamees Afify
    Lamees Afify avatar
    10 posts
    Member since:
    Mar 2008

    Posted 16 Sep 2008 Link to this post

    Hey,$0      I have a problem when trying to filter on "Contains" condition. The datacolumn in the database is of type int and I bound the datafield to a GridViewTextBoxColumn in the RadGrid. When I try to make a filter on Contains condition and once I type a number I got an error Cannot perform 'Like' operation on System.Int32 and System.String$0$0$0$0$0Is there anyway to fix that?$0
  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 16 Sep 2008 Link to this post

    Hi Lamees Afify,

    Thank you for your question.

    There is a work-around for this issue. You have to create a hidden string column:

    GridViewTextBoxColumn c = new GridViewTextBoxColumn();  
    c.DataType = typeof(string);  
    c.IsVisible = false;  
    this.radGridView1.MasterGridViewTemplate.Columns.Add(c);  
    c.Expression = "databasefieldhere"

    Please take care of adding this column just once, because the grid will consume too much memory. 

    Then you have to create a custom filter:

    FilterExpression filter = new FilterExpression(FilterExpression.BinaryOperation.AND, GridKnownFunction.Contains, GridFilterCellElement.ParameterName);  
                ParameterValuePair p = new ParameterValuePair(GridFilterCellElement.ParameterName, "99");  
                filter.Parameters.Add(p);  
                c.Filter=Filter;
        

     


    Then you can modify the filter using this code:

    p.Value="filtervalue" 
     

    Feel free to contact me if you have any further questions.

     
    Best wishes,
    Nick
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lamees Afify
    Lamees Afify avatar
    10 posts
    Member since:
    Mar 2008

    Posted 19 Sep 2008 Link to this post

    hey,
        Thanks for your reply, but whre should I add the line where I change the parameter value p.Value="filtervalue" ?
    Thanks again
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 19 Sep 2008 Link to this post

    Hi Lamees Afify,

    You should do that in the second code snippet, where the filter value is set to the string 99. You may change this value at any time in your code using the third snippet. For example, you may change the filter value to the string 17 using this code:

    p.Value="17"  

    Don't hesitate to contact me if you have further questions.

    Greetings,
    Nick
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Samira
    Samira avatar
    4 posts
    Member since:
    Feb 2014

    Posted 19 Feb 2014 Link to this post

    Hi,
    The value of column's filter descriptor disappeared after filtering. How can i fix it ?
  7. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 21 Feb 2014 Link to this post

    Hello Samira,

    Thank you for contacting us.

    The provided information is not enough for me to reproduce the problem on my end. The value in the filter cell is stored after filtering. Please refer to the attached screen shot. Could you please specify the exact steps how to reproduce the problem or get back to me with a sample code snippet so I can investigate the precise case? Information about the installed Telerik UI for WinForms version will be useful. Thank you in advance.

    I am looking forward to your reply.

    Regards,
    Desislava
    Telerik
  8. Samira
    Samira avatar
    4 posts
    Member since:
    Feb 2014

    Posted 22 Feb 2014 in reply to Dess Link to this post

    Hello Desislava,
    I wanted to filter a numeric column so I added a hidden column to the grid . When user entered the filter value in main column, the grid filtered but filter value at main column disappeared.
  9. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 27 Feb 2014 Link to this post

    Hello Samira,

    Thank you for writing back.

    I am still unable to reproduce the problem on my end with the latest version. I would kindly ask you to provide same code snippet, which successfully reproduces the issue. Thus, we would be able to investigate the specific case and assist you further. Thank you in advance for the co-operation.

    I am looking forward to your reply.

    Regards,
    Desislava
    Telerik
  10. Samira
    Samira avatar
    4 posts
    Member since:
    Feb 2014

    Posted 01 Mar 2014 in reply to Dess Link to this post

    Hello Desislava,

    Thank you for your attention.

    I wanted to use contain filter for numeric column so I used Nick's way and created a hidden string column to the grid.
    But when I filter Numeric column by contain filter and apply it on hidden string column , The value of column's filter descriptor disapeared.
  11. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 05 Mar 2014 Link to this post

    Hello Samira,

    Thank you for writing back.

    I would like to note that Nick's solution is relevant for the specified version (Q2 2008 SP1). Currently, our RadGridView is quite improved compared to 2008.

    Your question has already been answered in the forum thread you have opened. Please, see our answer there for more information. We kindly ask you to use just one thread for a specific problem.

    Thank you for your understanding.

    Regards,
    Desislava
    Telerik

    DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Back to Top
UI for WinForms is Visual Studio 2017 Ready