brandx
Posts: 29
|
| Posted: 05/08/2006, 6:38 AM |
|
setup a typical grid that pulls records into the page.. and the following is suppost to happen.
1. when the grid initially loads... only records where the field "featured" is "1" are shown.
2. There is also a serach to allow the records to be filtered by location.
The problem.
In the where statement for the grid....
clocation = s_clocation (For the search) (AND ..... OR )
featured = "1" For the featured
If i use and "AND".... records that are not marked featured never show up in the locations!
if i use a "OR"... records that are marked up as featured show up in every location!
... i realize the problem is i need a custom where statement....
If feature = 1
then
response.write bla bla.....
else
response.write....
I really have no idea how to handle this problem...
Can anyone help?
Geary
|
 |
 |
Frosty555
Posts: 7
|
| Posted: 05/08/2006, 11:58 AM |
|
So, initially the grid displays all records that are featured, regardless of their location. After you use the search feature to filter by location, you want records to appear for that location, regardless of their featured status?
Okay, this should be doable. Your grid's data source should have a where clause that looks something like this:
WHERE (clocation LIKE '%{s_clocation}%') AND....OR
featured = "1"
But I think what you want is to replace that with:
WHERE (clocation LIKE '%{s_clocation}%') AND
({s_clocation} <> "" OR featured = "1")
If the location search filter is specified, s_clocation <> "", and so the filter will include records regardless of their featured status.
If the location search filter is NOT specified, then the filter will display records in any location, but filtered only displaying the ones that are featured. This is the default behavior of the grid when loaded for the first time.
You should be able to do this using the Visual Query Builder in CodeCharge. Go to the grid's "Data Source" property, click the little three dots, then select the WHERE clause. The last row should be the location filter for the search query. Make that row finish with "AND" and then add a new row. Make the Set the condition type to be an expression and type
{s_clocation} <> "" OR featured = "1"
as the expression.
If your variables are named differently you might need to tweak that but I think that'll give you the behavior you want.
|
 |
 |
brandx
Posts: 29
|
| Posted: 05/08/2006, 12:56 PM |
|
Thanks for the response Frosty55
Here is the error i'm getting when i try to use what you've stated above.
Form: Grid cattery
Error: Malformed GUID. in query expression 'locid = 27 and ({s_clocation} <> "" OR cfeatured="1")'. (Microsoft JET Database Engine)
I've tried the code the following ways all producing the same error.
locid = {s_location} And
({s_clocation} <> "" OR cfeatured = "1"}
locid = {s_clocation} And
({s_clocation} <> {Expr1} Or
cfeatured = {Expr2})
Geary
|
 |
 |
brandx
Posts: 29
|
| Posted: 05/10/2006, 5:27 AM |
|
UPDATE!
Change in plans....
I've swiched to developing the frontend of the website to CodeCharge 2.x.x.... not CodeCharge Studio...
I"m still faced with the same problem though, can anyone help?
TIA,
Geary
|
 |
 |
|