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

get current value in FilterChanging event

3 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 02 Mar 2011, 12:27 PM
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

3 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Mar 2011, 12:37 PM
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
0
Patrick
Top achievements
Rank 1
answered on 02 Mar 2011, 12:57 PM
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
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 02 Mar 2011, 02:24 PM
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
Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Share this question
or