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
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
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.
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
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
" ---select --" in fields options.
It is possible?
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.
How I can do this?
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.
Such as a combo Box but in FieldEditor:
---Select---
Field1
Field2
Field3
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.
Are any example of this on code Library or Other forum?
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.
I attach an image with What I need.
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 >>