CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Apply search criteria on grid's initial load?

Print topic Send  topic

Author Message
VBAjedi


Posts: 34
Posted: 07/26/2004, 3:32 PM

This has probably been addressed in this forum, but I can't seem to find it.

I have a standard search & grid page. One of the search controls is set to Retrieve Value for Control (from a session variable) in the server-side Before Show event. That part works.

But how do I get the associated grid to load with that search criteria already applied? It currently loads all records in the table, so the user has to click the Search button on the search form to see the correct subset of the data (as specified by the value I retrieved in the Before Show event of the search field control). I want users to be able to click on the link to this page, and have it load initially with the grid only displaying the relevant rows (as opposed to all records).

Thanks for your assistance on this. . . hope I was clear.
_________________
VBAjedi
jedi at NOSPAM dot obie dot com
View profile  Send private message
Damian
Posted: 07/26/2004, 6:19 PM

Apply the parameters in the GRID's Data Source.

"VBAjedi" <VBAjedi@forum.codecharge> wrote in message
news:54105868538c89@news.codecharge.com...
> This has probably been addressed in this forum, but I can't seem to find
it.
>
> I have a standard search & grid page. One of the search controls is set to
> Retrieve Value for Control (from a session variable) in the server-side
Before
> Show event. That part works.
>
> But how do I get the associated grid to load with that search criteria
already
> applied? It currently loads all records in the table, so the user has to
click
> the Search button on the search form to see the correct subset of the data
(as
> specified by the value I retrieved in the Before Show event of the search
field
> control). I want users to be able to click on the link to this page, and
have it
> load initially with the grid only displaying the relevant rows (as opposed
to
> all records).
>
> Thanks for your assistance on this. . . hope I was clear.
> _________________
> VBAjedi
> jedi at NOSPAM dot obie dot com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

VBAjedi


Posts: 34
Posted: 07/27/2004, 1:49 PM

Not sure what you are suggesting. I already have that search field set up in one of my grid Data Source "where" statements. It works great for manual searches, but it's like it just ignores the value I'm sticking into the search control (via code when the page first loads) and loads all values for that column. I can see the desired value in the Search control after the page loads, but I have to manually click the Search button to narrow down the list.
_________________
VBAjedi
jedi at NOSPAM dot obie dot com
View profile  Send private message
VBAjedi


Posts: 34
Posted: 07/29/2004, 9:16 AM

<bump>

Anyone?
_________________
VBAjedi
jedi at NOSPAM dot obie dot com
View profile  Send private message
Don Safar
Posted: 07/29/2004, 10:51 AM

Your datasource where is probably set it up to retrieve from URL. Add
another param (use or) to retrieve from session or append to Where clause in
beforeshow event.

"VBAjedi" <VBAjedi@forum.codecharge> wrote in message
news:54106bfc628f74@news.codecharge.com...
> Not sure what you are suggesting. I already have that search field set up
in one
> of my grid Data Source "where" statements. It works great for manual
searches,
> but it's like it just ignores the value I'm sticking into the search
control
> (via code when the page first loads) and loads all values for that column.
I
> can see the desired value in the Search control after the page loads, but
I
> have to manually click the Search button to narrow down the list.
> _________________
> VBAjedi
> jedi at NOSPAM dot obie dot com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

aradi

Posts: 66
Posted: 07/29/2004, 10:54 AM

Hi,

Check the CCS Studio Help and search on "Dynamically Modify the WHERE Clause"
There is an example shows how to modify the WHERE clause of a Grid form. Within an SQL statement, the Where clause is used to specify the criteria which will be used to select database records. So you need to change it in the Before Build Select Event code. Get the session variable first then include it in the WHERE Clause this will allows you to narrow the list dynamically ,using the session variable, when the page loads .

I hope that is what you want.


View profile  Send private message
VBAjedi


Posts: 34
Posted: 07/29/2004, 1:20 PM

Don and aradi,

Thanks for the pointers! Don, you were right about my Where clause retrieving from the URL (which is obviously empty when the page first loads). Aradi, the help example you pointed me to got me going in the right direction.

The following code, placed in the BeforeBuildSelect event of a grid, will construct a Where statement from a global variable if there is currently no Where statement (like when the page first loads):

global $spacekey; // your form
if (empty($spacekey->ds->Where)) {
$spacekey->ds->Where = " MyColName = '" . CCGetSession("MyGlobalVariable") . "'";
}

Hope that helps someone else as much as it helped me!
_________________
VBAjedi
jedi at NOSPAM dot obie dot com
View profile  Send private message
czevak
Posted: 07/18/2005, 2:16 AM

Thank you very much for this little piece of code!

It helped me a lot! :-)

Regards Czevak.
dsafar
Posted: 07/18/2005, 7:22 PM

You can also do the same thing in the query builder just specify the default
for the URL parameter
as CCGetSession("MyGlobalVariable")
If one is not passed, it will use the session variable.

"VBAjedi" <VBAjedi@forum.codecharge> wrote in message
news:541095c1cdf180@news.codecharge.com...
> Don and aradi,
>
> Thanks for the pointers! Don, you were right about my Where clause
> retrieving
> from the URL (which is obviously empty when the page first loads). Aradi,
> the
> help example you pointed me to got me going in the right direction.
>
> The following code, placed in the BeforeBuildSelect event of a grid, will
> construct a Where statement from a global variable if there is currently
> no
> Where statement (like when the page first loads):
>
> global $spacekey; // your form
> if (empty($spacekey->ds->Where)) {
> $spacekey->ds->Where = " MyColName = '" .
> CCGetSession("MyGlobalVariable")
> "'";
> }
>
> Hope that helps someone else as much as it helped me!
> _________________
> VBAjedi
> jedi at NOSPAM dot obie dot com
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.