This topic is locked
[SOLVED]

 limit default list

5/6/2008 10:42:49 PM
ASPRunnerPro General questions
T
Tim author

Is there a way to limit the initial view on a list page? For instance, I would like the first view of the list page to only show records where the "Task Owner" field = Session("UserID"), but if they click show all it will show all records. And searches aren't limited to the initial limited list, but will include all.
Thanks,

Tim

J
Jane 5/7/2008

Tim,
try to use this code in the List page: Before SQL query event on the Events tab:

if REQUEST("a")<>"search" and REQUEST("a")<>"advsearch" and REQUEST("a")<>"showall" then

strWhereClause = whereAdd(strWhereClause,"Task Owner='" & Session("UserID") & "'")

end if

T
Tim author 5/7/2008

That works great! Thanks Jane. Now that I see what you did, I never would have got that on my own. Thanks so much.
One little quirky thing. No big deal if it has to be, but... once I click on show all, it shows all correctly. When there are more than 20 records it creates a second page. When I click on page 2 it again limits the list by Task Owner.
Now that I think about this I'm not even sure what I'd want it to do, because if the Task Owner did have more than 20 tasks I think I'd want page 2 to be limited to their tasks in that situation. So it's like, only if they've clicked show all or done some other kind of search, go with normal behavior, otherwise always be limited by Task Owner. Wow. Is that even possible. Like I said... I think I could live with it the way it is if I have to.
Thanks,

Tim

J
Jane 5/8/2008

Tim,
unfortunately there is no easy way to change SQL query for show all option.

Try to use simple or advanced search and following code in the List page: Before SQL query event:

if SESSION(strTableName & "_search")<>1 and SESSION(strTableName & "_search")<>2 then

strWhereClause = whereAdd(strWhereClause,"Task Owner='" & Session("UserID") & "'")

end if