Save Filter in a database

10 posts, 0 answers
  1. Joseph Duncan
    Joseph Duncan avatar
    1 posts
    Member since:
    Oct 2009

    Posted 16 Mar 2010 Link to this post

    Hi there,

    I searched the CHM but I wasn't able to find the answer.  Is it possible to build a filter using this control and save it in a database?  We have a need to build a filter which is read by a database job for other processing.  The saved filter all needs to be retrieved and displayed so users can modify the filter.  Is this possible?

    Regards,
    Joseph


  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 18 Mar 2010 Link to this post

    Hello Joseph,

    In general on ApplyExpressions event you have access to e.ExpressionRoot which contains the root of all build expressions. You can use to traverse the expressions and save them. For your convenience I've prepared sample application that demonstrates how to dynamically save/load all expressions to RadFilter in Session(which could be replaced by DB in your implementation).

    Regards,
    Nikolay
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prateek Bahl
    Prateek Bahl avatar
    8 posts
    Member since:
    Dec 2009

    Posted 18 Mar 2010 Link to this post

    This code will provide you with the SQL query generated by the filter.

    RadFilterSqlQueryProvider provider = new RadFilterSqlQueryProvider(); 
    provider.ProcessGroup(RadFilter1.RootGroup); 
    String result = provider.Result; 


    Hope this helps,

    Prateek
  5. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 09 Jun 2010 Link to this post

    Please Post the code for save the grid state in the database with the Filter save in database.
  6. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 09 Jun 2010 Link to this post

    Hello Mandeep,

    You can combine the solution posted by my colleague Nikolay in this thread with the sample code snippets available in this online demo (or that from the code library thread linked in the help topic under the Description tab there).

    Best 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.
  7. Prateek Bahl
    Prateek Bahl avatar
    8 posts
    Member since:
    Dec 2009

    Posted 09 Jun 2010 Link to this post

    look at the following link:
    http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html

    Prateek
  8. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 10 Jun 2010 Link to this post

    Hi,
    Thanks for the reply,
     now i am able to create the radfilter saved state from database.
    but the problem arise when i am again click on load the settings button for another saved setting in the database.
    it create the filter state but the previous state is also stay there. i.e. radfilter is not reset.

    Please reply ASAP.

    Thanks in Advance..
  9. Prateek Bahl
    Prateek Bahl avatar
    8 posts
    Member since:
    Dec 2009

    Posted 10 Jun 2010 Link to this post

    Are you clearing the column settings before saving and/or loading the expression?  Look for the 'SaveColumnSettings()' method in the link I posted above.
  10. Chad
    Chad avatar
    7 posts
    Member since:
    Jun 2009

    Posted 10 Jun 2010 Link to this post


    The above example doesn't work, if you click save and then load you get the original filters plus the saved filters.

    If you click save, Reload the page so that the RadFilter control is empty and try to reload the filters, no filters are added.

    I guess you could iterate through all the expressions but this seems to be a little work.

  11. Mandy
    Mandy avatar
    33 posts
    Member since:
    Mar 2010

    Posted 11 Jun 2010 Link to this post

    Just Paste one line over the code where you going to create radfilter dynamically.
    like given Below.


    RadFilter1.RootGroup.Expressions.Clear();

     

     

     

    ExpressionPersister persister = new ExpressionPersister();

     

    ((

    IStateManager)RadFilter1.RootGroup).LoadViewState(persister.Load(AA));

     

    RadFilter1.RecreateControl();

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