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

Setting filter function via custom FieldEditor

2 Answers 73 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Josh Turpen
Top achievements
Rank 1
Josh Turpen asked on 20 May 2011, 11:55 PM

I've created a custom field editor which has:

Two radio buttons, radio1, radio2 with autopostback = true
A text box
A combo box (as described in the demo : http://www.telerik.com/help/aspnet-ajax/filter-custom-editors.html)

I have it coded like this:

When radio1 is selected, the textbox is visible, and the filter functions are EqualTo, NotEqualTo, Contains, Between, etc. 
When radio2 is selected, the combo box is visible, and the only filter function is EqualTo.

My problem is when radio2 is selected, I can't figure out how to set the selected filter to EqualTo.  For example, If radio1 is selected and the selected filter function is 'Contains', and then they select radio2, I can't set the selected filter to 'EqualTo'.  I can reduce the options available in the context menu successfully when radio2 is clicked, but I can't set the selected filter.

Please help :)

Thanks,
Josh

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 26 May 2011, 11:21 AM
Hi Josh,

Unfortunately the RadFilter could not support the desired functionality. You could not change the filter function on radio button click. Also the filter function depends on the field data type by which the data will be filtered. You could only change the initial filter function by using the following code snippet:
void RadFilter1_ItemCommand(object sender, RadFilterCommandEventArgs e)
    {
        if (e.CommandName == RadFilter.AddExpressionCommandName)
        {
            e.Canceled = true;
            RadFilterContainsFilterExpression item = new RadFilterContainsFilterExpression(RadFilter1.FieldEditors[0].FieldName);
            (e.ExpressionItem as RadFilterGroupExpressionItem).Expression.AddExpression(item);
            RadFilter1.RecreateControl();
        }
    }

This will select the "Contains" filter function as default function.

I hope this helps.

Best wishes,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Josh Turpen
Top achievements
Rank 1
answered on 26 May 2011, 04:24 PM
Thanks for the update.
Tags
Filter
Asked by
Josh Turpen
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Josh Turpen
Top achievements
Rank 1
Share this question
or