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

Add new field e exec a custom query in radfilter

16 Answers 160 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Silvio Silva Junior
Top achievements
Rank 2
Silvio Silva Junior asked on 15 Feb 2011, 01:58 PM
Hi everyone.

I'm looking for a solution to add a new field to my radfilter, and when this field be selected, I want to exec a especific query in my database.

Ex:

I have a grid (connected to the filter) with 3 fields:

Customer, Company, Salary --> This works perfectly with the filter.

What I want is to add a field called "All" that doesn't appear in grid, but is showed in filter. When the user select this field and apply filtering, I want to exec my custom stored procedure and bind the grid with the data retrieved.

What's the best way?

Thanks in advance.

16 Answers, 1 is accepted

Sort by
0
Silvio Silva Junior
Top achievements
Rank 2
answered on 16 Feb 2011, 07:33 PM
There's no solution for it?
0
Nikolay Rusev
Telerik team
answered on 18 Feb 2011, 05:32 PM
Hello Silvio,

If you are using RadFilter with integration with RadGrid you are limited to the fields that RadGrid lists.

However you can define the fields on your own, i.e FieldEditors collection and build custom editors. You will need to handle ApplyExpressions and process the expressions view one of the build-in query providers(such as RadFilterSqlQueryProvider) or extend them.

All the best,
Nikolay
the Telerik team
0
Silvio Silva Junior
Top achievements
Rank 2
answered on 24 Feb 2011, 05:44 PM
Hello, and thanks for the answer.

Can you explain with some examples please?

 For example, I have a custom stored procedure, and I want to pass some parameters it based on the filter. How can I handle these ApplyExpressions to do it?

Thanks in advance.

Regards.
0
Nikolay Rusev
Telerik team
answered on 02 Mar 2011, 10:54 AM
Hello Silvio,

Given the following RadFilter declaration:
<telerik:RadFilter runat="server" ID="Filter">
            <FieldEditors>
                <telerik:RadFilterTextFieldEditor FieldName="Field1" />
                <telerik:RadFilterNumericFieldEditor FieldName="Field2" />
            </FieldEditors>
        </telerik:RadFilter>

You can handle ApplyExpressions and process the groups via RadFilterSqlQueryProvider and supply it of your stored procedure.

void Filter_ApplyExpressions(object sender, Telerik.Web.UI.RadFilterApplyExpressionsEventArgs e)
    {
        var provider = new RadFilterSqlQueryProvider();
        provider.ProcessGroup(e.ExpressionRoot);
        //provider.Result; - Result contains the string representation of the SQL where clause
    }

The link explains how to build the where clause dynamically.
http://www.sqlteam.com/article/implementing-a-dynamic-where-clause

Regards,
Nikolay
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
reza
Top achievements
Rank 1
answered on 06 Apr 2011, 08:56 PM
hi, is there anyway that the radfilter automatically detect type of editor the field require.for example by passing the propertyInfo or an entity
0
Sebastian
Telerik team
answered on 07 Apr 2011, 07:40 AM
Hi reza,

Not sure whether I understood your question correctly, but I think this is how RadFilter works by default, i.e. the filter editor for the corresponding field is dynamically set based on the type of the data source field. You can verify that on the First Look demo of the filter control.

Regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
July
Top achievements
Rank 2
answered on 16 Aug 2011, 07:21 PM
I need add a label like this

" ---select --"   in fields options.

It is possible?
0
Iana Tsolova
Telerik team
answered on 17 Aug 2011, 10:08 AM
Hello Julieta,

You can create your own field editor for your purpose.
Check the below demo:
http://demos.telerik.com/aspnet-ajax/filter/examples/customeditors/defaultcs.aspx

Regards,
Iana
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
July
Top achievements
Rank 2
answered on 17 Aug 2011, 01:04 PM
I need set  "-- select --" in field combobox without textbox and options ( equal, contains)
How I can do this?
0
Iana Tsolova
Telerik team
answered on 18 Aug 2011, 10:04 AM
Hello Julieta,

You can create custom DropDownEditor as in the mentioned demo. However instead of binding to a datasource, add the desired items directly to it.

I hope this helps.

Kind regards,
Iana
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
July
Top achievements
Rank 2
answered on 18 Aug 2011, 02:33 PM
Sorry I don't say that I need "--select--" in FieldEditor section....

Such as a combo Box but in FieldEditor:
---Select---
Field1
Field2
Field3


0
Iana Tsolova
Telerik team
answered on 18 Aug 2011, 03:58 PM
Hi Julieta,

Indeed, for that purpose you should create custom editor which will display a RadComboBox with the desired values.

Kind regards,
Iana
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
July
Top achievements
Rank 2
answered on 19 Aug 2011, 12:47 PM

Are any example of this on code Library or Other forum?
0
Iana Tsolova
Telerik team
answered on 19 Aug 2011, 02:37 PM
Hello Julieta,

If you have the controls installed, you should be able to find the local version of the demo running the Sample Web Site in Visual Studio. You can also find the code in this help article.

All the best,
Iana
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
July
Top achievements
Rank 2
answered on 19 Aug 2011, 03:40 PM
Yes, I have this cod, but I ask for a example of "select" in filter.....
I attach an image with What I need.

0
Iana Tsolova
Telerik team
answered on 22 Aug 2011, 10:15 AM
Hello Julieta,

Thank you for the screenshot. Now I see what you mean. However this is not possible.
This is how RadFilter works: When you choose to Add  Expression, as selected field comes the first data field from the FieldEditors collection of RadFilter. This collection is built two ways: automatically, if RadFilter is connected to a control; manually, if you have the FieldEditors declaratively defined. 
So the only way o display --select-- values as the default selected one, you should have a FieldEditor which DisplayName is set to --select--. But for the RadFilter to work properly, you should still have a valid FieldName bound to this field editor.  

Greetings,
Iana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Filter
Asked by
Silvio Silva Junior
Top achievements
Rank 2
Answers by
Silvio Silva Junior
Top achievements
Rank 2
Nikolay Rusev
Telerik team
reza
Top achievements
Rank 1
Sebastian
Telerik team
July
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or