CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

  [Resolved] Hide report if emtpy

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 07/30/2008, 8:36 PM

So.. pulling my hair out here. I have a page with several reports, in panels and I want them to be hidden if they have no records. I can do it with Grids.. but Reports seem to be stubborn.
I have tried the following snippets on the BS event of the Report... then on the panel that the report is in. Nothing works.

What am I missing?

if ($Container->DataSource->RecordsCount == 0)  
{  
     $Container->Visible = False;  
}

$Component->Visible = ($gridname->DataSource->RecordsCount > 1);  

$Component->Visible = false;  
   if ($Container->DataSource->RecordsCount > 0)   
  {  
       $Component->Visible = true;  
    }  

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
wkempees


Posts: 1679
Posted: 07/31/2008, 2:15 AM

[edited] wrong, read later post

In the report Before Show

  
  
// -------------------------  
	if ($Component->NoRecords == true)  
	$Component->Visible =False;  
//End Custom Code  
  
(tested)

greetings, friend

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
ckroon

Posts: 869
Posted: 07/31/2008, 4:04 PM

Thanks Walter that was it! O:)
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit
Posted: 07/31/2008, 4:14 PM

....but I'm totally curious as to why this didn't work:

  
if ($Container->DataSource->RecordsCount == 0)  
{  
      $Container->Visible = False;  
}  

Is it just on 'Reports' that it doesn't work?
ckroon

Posts: 869
Posted: 07/31/2008, 4:20 PM

Actually, now I am confused as well.. I thought it worked when I saw the report disappear... but it stays invisible even if there are records in it...strange.. investigating....
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
ckroon

Posts: 869
Posted: 07/31/2008, 7:12 PM

Ok. Jmancera gave me a hand with this. Very strange stuff. IT worked on his server.. but not on my local machine or my dedicated server.. the following code DID work however...

 $sql = $Component->DataSource->SQL;  
        $sql = str_replace("{SQL_Where}"," where " . $Component->DataSource->Where,$sql);  
        $sql = str_replace("{SQL_OrderBy}","",$sql);  
        $db = new clsDBConnection1;  
        $db->query($sql);  
        if ($db->num_rows() == 0)  
        {  
             $Component->Visible = False;  
        }

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/01/2008, 2:44 AM

Ok, so I was wrong, thanks for pointing out being half a magician.
Made the report disapear to never appear again.

The shorthand for the above solution:
And
my corrected post:

Event AfterExecuteSelect
  
     if ( $Component->ds->num_rows() == 0)  
          $Component->Visible = False;  
  
[/code  
  
Effectively the same solution as above except that it will use the result of the already defined/existing SQL  
  
Walter  
O:) 
                  
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/01/2008, 3:01 AM

@Datadoit
RecordsCount
is set in Grids by the CountSQL, executed before the actual dataset is retreived.
This piece of code is not in the basic Reportcode.
Might be that it is needed for the Navigation (Next/Previous page).

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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