CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 CCS: Filtering records

Print topic Send  topic

Author Message
Brent
Posted: 05/13/2002, 12:39 PM

I want to filter records in a grid. I can't do this in the SQL's where clause
because the filtering depends on calculations that are done on the record
and the previous record.

I thought I could put the code into grid_beforeshow() event. But if I reject
the record, how do I convey this back to the loop in the Show function so it
executes a (PHP) Continue so it excludes this record? There should be some way
of returning a True/False from the event code and having the loop include or
reject the record respectively.

TIA
Nicole
Posted: 05/14/2002, 2:50 AM

Brent,
if you mean that displaying of the field depends on the value of previous record from recordset I suggest you to move pointer to next record in Before Show Row event.
E.g.:
global $form_name;
if (condition_to_pass_record)
$form_name->ds->next_record();


Brent
Posted: 05/14/2002, 7:27 AM

>If you mean that displaying of the field depends on the value of previous record from recordset
>I suggest you to move pointer to next record in Before Show Row event.
>E.g.:
>global $form_name;
>if (condition_to_pass_record)
> $form_name->ds->next_record();

Well, this almost works. :)
I would have to put a loop in the event because it may have to skip 1 or more records.
There is also the other problem of hitting EOF in my loop. It will exit out and then
returns to the calling code which then accesses the data in the non-existant row.

It would be much easier if the event could pass back a value to the calling code
either as the result of the function or as a parameter that would tell it to conditionally
skip processing this record and fetch another record.

I don't see any other way around this problem, can you?
CodeCharge Support
Posted: 05/15/2002, 12:06 AM

Brent,
here is workaround how to achieve the result you want, i.e. how to skip record show. First of all create Before Show Row event that returns any result, e.g.:
if (condition_to_show)
return 1;
else
return 0;

Then open code file. It requires a little modification. Find Show() function of clsGrid<form_name> class. Go to line where BeforeShowRow event result it returned. You'll see that right after it code goes that is used to display fields in a row. E.g.:
...
$this->CCSEventResult = CCGetEvent($this->CCSEvents["BeforeShowRow"]);
$Tpl = $this->bug_id->Show($Tpl);
$Tpl = $this->bug_name->Show($Tpl);
$ShownRecords++;
$is_next_record = $this->ds->next_record();
} while ($is_next_record && $ShownRecords < $this->PageSize);

As some result is returned by before show row you can check it here in Show() function and depending on its value executes show() code for the fields, e.g.:
...
$this->CCSEventResult = CCGetEvent($this->CCSEvents["BeforeShowRow"]);
if ($this->CCSEventResult == 1)
{
$Tpl = $this->bug_id->Show($Tpl);
$Tpl = $this->bug_name->Show($Tpl);
}
$ShownRecords++;
$is_next_record = $this->ds->next_record();
} while ($is_next_record && $ShownRecords < $this->PageSize);

So show fields code could be skipped.

   


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.