get current value in FilterChanging event

4 posts, 1 answers
  1. Patrick
    Patrick avatar
    14 posts
    Member since:
    Feb 2011

    Posted 02 Mar 2011 Link to this post

    Hi,

    my name is Patrick and i just bought Telerik Premium Collection for .NET.
    I've searched the forums and documentation but could not found any answer for my simple problem;(

    So here is my question:
    how do i get the FULL value of my Filter in RadGrid?

    My Code:

    private void rgCustomer_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
            {
                if (e.NewItems.Count > 0)
                {
                    FilterDescriptor desc = e.NewItems[0] as FilterDescriptor;
                    if (desc != null)
                    {
                        if (desc.Value.ToString().Length < 3)
                            e.Cancel = true;
                    }
     
                }
                 
            }
    The Problem is: desc.Value only returns the current letter i've typed.
    Example: if i enter "test" -> desc.Value is "t"

    thx for help
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Mar 2011 Link to this post

    Hello Patrick and welcome to the forums,

    First of, in the FilterChanging event you will only be able to get the value always one step behind the actual value, so if you have typed "te" in the filter box and then type s in the value changing event you will be receiving "te" as the value, and on the next keystroke you will receive the s also.

    I believe there is a bug somewhere around this.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Patrick
    Patrick avatar
    14 posts
    Member since:
    Feb 2011

    Posted 02 Mar 2011 Link to this post

    Hi again :)

    thanks for help but i think you missunderstood me.
    the goal for my intention is that if i enter something in the filter - textbox the filter action should only execute if the text.length property is >= 3. Actually the problem is i only get the FIRST letter of my filter-textbox.
    Example: Filter value is "hello"  the desc.Value.ToString()  result is "h".

    Sorry for my bad english but im not a native speaker :)

    thanks
  5. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Mar 2011 Link to this post

    Hello again Patrick,

    Please try this option for doing what you need:
    void radGridView1_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
    {
        if (e.Action == NotifyCollectionChangedAction.Remove)
        {
            return;
        }
     
        if (radGridView1.ActiveEditor.Value.ToString().Length < 3)
        {
            e.Cancel = true;
        }
    }

    And also, i have provided a solution on a thread where filtering is just applied on cell leave, to improve the performance of the grid.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
Back to Top