Add new field e exec a custom query in radfilter

17 posts, 0 answers
  1. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 15 Feb 2011 Link to this post

    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.
  2. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 16 Feb 2011 Link to this post

    There's no solution for it?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 18 Feb 2011 Link to this post

    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
  5. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 24 Feb 2011 Link to this post

    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.
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 02 Mar 2011 Link to this post

    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!
  7. reza
    reza avatar
    6 posts
    Member since:
    Jan 2009

    Posted 06 Apr 2011 Link to this post

    hi, is there anyway that the radfilter automatically detect type of editor the field require.for example by passing the propertyInfo or an entity
  8. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 07 Apr 2011 Link to this post

    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
  9. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    I need add a label like this

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

    It is possible?
  10. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Aug 2011 Link to this post

    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.

  11. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 17 Aug 2011 Link to this post

    I need set  "-- select --" in field combobox without textbox and options ( equal, contains)
    How I can do this?
  12. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 18 Aug 2011 Link to this post

    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.

  13. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 18 Aug 2011 Link to this post

    Sorry I don't say that I need "--select--" in FieldEditor section....

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


  14. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 18 Aug 2011 Link to this post

    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.

  15. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 19 Aug 2011 Link to this post


    Are any example of this on code Library or Other forum?
  16. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 19 Aug 2011 Link to this post

    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.

  17. July
    July avatar
    205 posts
    Member since:
    Jul 2011

    Posted 19 Aug 2011 Link to this post

    Yes, I have this cod, but I ask for a example of "select" in filter.....
    I attach an image with What I need.

  18. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 22 Aug 2011 Link to this post

    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 >>

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017