View Full Version : DataAssist Search / Result / Clear Result
muddysmurf
03-08-2009, 12:30 PM
First of all I'm probably doing something stupid to make this not work, but I need some help.
I've set up my search form to search a certain table in my database. My results page comes up with the certain number of results on the page. I have a button to go back to the page that lists all of the items in my table. When you click that button, it then goes to that page but keeps the search results. I'd hit f5 and it wouldn't change, then I would clear cache and cookies in Firefox (newest version and IE7) and it would show up what I wanted.
Well I then enabled a clear session variable (using Cookie Toolkit) and set a cookie for -20 days on page submit (from my results page). Then when you clicked the link it would take you to the same results you looked for, but this time if you hit f5 it would refresh to every listing in my table (what I wanted).
What am I doing wrong? I need this to work on the first time when someone wants to list all of the table data.
Thanks!
Danilo Celic
03-08-2009, 03:01 PM
The DataAssist search results page has built in functionality that causes any search to be saved so that if the visitor comes back to the page (such as going to the detail page and then update page and then back to the results page) that the search will still be present.
If that isn't the desired behavior, then you can work around it by linking to the results page and add in a "fake" query string value such as results.php?clear=true
This will cause the "search save" feature to think that another search is being performed with no search criteria (assuming that "clear" isn't the name of one of your search fields), which will show all of the records.
HTH
muddysmurf
03-08-2009, 03:25 PM
The DataAssist search results page has built in functionality that causes any search to be saved so that if the visitor comes back to the page (such as going to the detail page and then update page and then back to the results page) that the search will still be present.
If that isn't the desired behavior, then you can work around it by linking to the results page and add in a "fake" query string value such as results.php?clear=true
This will cause the "search save" feature to think that another search is being performed with no search criteria (assuming that "clear" isn't the name of one of your search fields), which will show all of the records.
HTH
I couldn't get that to work, so I searched the code on the results page, and just took out the portion that saved the session. I'll add it back if I start to run into some problems, but it seems to work pretty good right now lol
Thanks!
Danilo Celic
03-08-2009, 03:28 PM
Well, I guess that that is always an option. :-) Good luck with your project.
Ray Borduin
03-09-2009, 08:09 AM
What will break in this scenario is results pages with pagination... since when you navigate to the next page it will clear the results and show the second page of an unfiltered recordset.
If you don't ever use recordset pagination and show all of the records on the first page, it wouldn't be a problem.
muddysmurf
03-10-2009, 01:10 PM
What will break in this scenario is results pages with pagination... since when you navigate to the next page it will clear the results and show the second page of an unfiltered recordset.
If you don't ever use recordset pagination and show all of the records on the first page, it wouldn't be a problem.
That makes sense. I will probably add that later on, as there are not that many items for this page at the time.
Do you think if I create another recordset (that's basically the recordset I'm searching, just another name) on the page I want to go back to (the show all button) that it will work how I need it to?
Ray Borduin
03-11-2009, 07:50 AM
All you have to do is create the show all button to trigger the dataassist search server behavior. I beleive the trigger is based on a GET variable. Just add that trigger value to the link with any value and the result set will be cleared.
pdesignz
03-11-2009, 07:56 AM
Could you explain in more detail how to do this.
Thanks
Ray Borduin
03-11-2009, 08:00 AM
Open up the dataassist server behavior. Note the value of the trigger.
If it has something like $_GET['thisvalue'] in the trigger, then a link to the page like:
page.php?thisvalue=0
would clear the filter.
muddysmurf
03-11-2009, 08:54 AM
Thanks, Ray! I will try this when I get home. I'm a full time web designer - and then I'm a freelancer when I get home haha Seems I can't get enough of web design and Web Assist Products have helped TREMENDOUSLY!
info302926
03-13-2009, 11:37 AM
or page.asp?offset=0
Ray Borduin
03-13-2009, 11:53 AM
That would take you to the first page, but not clear the old DataAssist Search results, which are stored in the session and only updated when the trigger fires.
tige247759
09-16-2009, 08:27 AM
I have struggled with this too. Most of the advice didnt quite work the way it was intended and that results page tenaciously held onto the search results. I found a non invasive solution using two conditional statements. I have tested it and it seams to do the trick. I thought I'd post it here as it may be of use to others.
When data assist conducts a search, it stores that fact in a session variable. That session variable will have a custom name. This is easily located by looking for where it is set in the code. So first, you put a conditional statement in that sees when the session variable for that search result is set. If so, add a link with your own custom url string trigger attached.
<cfif (isDefined("Session.WADbSearch1_officials_Results") AND Session.WADbSearch1_officials_Results NEQ "")> / <a href="officials_Results.cfm?clearsearch=true">Clear Search and Return to Results</a></cfif>
I added this code right beside the New Search link in the header as that is where I wanted it to appear if a search had been initiated. Then, at the top of the code, before the cfscript code that deals with the session variable, I added this bit of conditional logic:
<cfif (isDefined("URL.clearsearch") AND URL.clearsearch EQ "true")>
<cflock timeout=20 scope="Session" type="Exclusive">
<cfset StructDelete(Session, "WADbSearch1_officials_Results")>
</cflock>
</cfif>
Which in a nutshell detects if your custom url string is present and if so clears out the session variable set via the search. You get a clean set of results returned in the SQL statement and because the session is no longer present, the link to clear the results does not appear.
Hope this helps. I know its a hack solution but it works and could be easily adapted for ASP or PHP.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.