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

Save Filter in a database

9 Answers 323 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Joseph Duncan
Top achievements
Rank 1
Joseph Duncan asked on 16 Mar 2010, 03:43 PM

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


9 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 18 Mar 2010, 09:27 AM
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.
0
Prateek Bahl
Top achievements
Rank 1
answered on 18 Mar 2010, 08:08 PM
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
0
Mandy
Top achievements
Rank 2
answered on 09 Jun 2010, 03:34 PM
Please Post the code for save the grid state in the database with the Filter save in database.
0
Sebastian
Telerik team
answered on 09 Jun 2010, 04:11 PM
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.
0
Prateek Bahl
Top achievements
Rank 1
answered on 09 Jun 2010, 04:14 PM
look at the following link:
http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html

Prateek
0
Mandy
Top achievements
Rank 2
answered on 10 Jun 2010, 06:44 AM
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..
0
Prateek Bahl
Top achievements
Rank 1
answered on 10 Jun 2010, 01:39 PM
Are you clearing the column settings before saving and/or loading the expression?  Look for the 'SaveColumnSettings()' method in the link I posted above.
0
Chad
Top achievements
Rank 1
answered on 10 Jun 2010, 10:07 PM

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.

0
Mandy
Top achievements
Rank 2
answered on 11 Jun 2010, 12:33 PM

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();

Tags
Filter
Asked by
Joseph Duncan
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Prateek Bahl
Top achievements
Rank 1
Mandy
Top achievements
Rank 2
Sebastian
Telerik team
Chad
Top achievements
Rank 1
Share this question
or