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

read filter expressions entered by user

3 Answers 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ravindar
Top achievements
Rank 1
ravindar asked on 25 Apr 2014, 03:11 AM
Hello friends,
i have RadFilterControl for date range. i mean we have to enter from date and to date for filtering data.
my requirement is , i have to get the to date entered by user and have to add 5 hours to it. 
i am planning to do this in Itemcommand event before calling FireApplyCommand(). 
so i have to read the end date entered by user and have to read it , add 5 hours to it, and then apply the filter.
could you guide me how to read the values entered by the user.

3 Answers, 1 is accepted

Sort by
0
ravindar
Top achievements
Rank 1
answered on 25 Apr 2014, 03:18 AM
by the way, i have tried following way
but  i am getting string to Pair type conversion error
if (e.CommandName == RadGrid.FilterCommandName)
{
Pair filterPair = (Pair)e.CommandArgument;
gridMessage1 = "Current Filter function: '" + filterPair.First + "' for column '" + filterPair.Second + "'";
TextBox filterBox = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].Controls[0] as TextBox;
gridMessage2 = "<br> Entered pattern for search: " + filterBox.Text;
}





0
ravindar
Top achievements
Rank 1
answered on 25 Apr 2014, 03:32 AM
also i have tried following way. But this is not returning user entered value. Its returning default value set while page load

for (i = 0; i < RadFilter1.RootGroup.Expressions.Count; i++)
                {
                    RadFilterFunction filterFunction = RadFilter1.RootGroup.Expressions[i].FilterFunction; // the filter function that was used for filtering
                    string a = filterFunction.ToString();
                    string fieldName = RadFilter1.FieldEditors[i].FieldName;
                    if (fieldName == "InsertedDateTime")
                    {
                        //RadGrid1.MasterTableView.AllowCustomSorting = true;
                        //read existing filter
                        RadFilterNonGroupExpression nonGroupExpression = RadFilter1.RootGroup.FindByFieldName(fieldName);
                        RadFilterBetweenFilterExpression<System.DateTime?> expression = nonGroupExpression as RadFilterBetweenFilterExpression<System.DateTime?>;
                        string leftValue = expression.LeftValue.ToString();
                        System.DateTime? startdate = expression.LeftValue;
                        System.DateTime? enddate = expression.RightValue;

0
ravindar
Top achievements
Rank 1
answered on 25 Apr 2014, 04:16 AM
i fixed it by calling recreate method.
RadFilter1.RecreateControl();
Tags
General Discussions
Asked by
ravindar
Top achievements
Rank 1
Answers by
ravindar
Top achievements
Rank 1
Share this question
or