CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Dinamically change the database table name used by grid

Print topic Send  topic

Author Message
sorinbuda

Posts: 27
Posted: 08/11/2016, 4:23 PM

Hi,

Is there a way to change dinamically the name of the database table used by a grid?
I have diffrent views created in the database with the same fields inside and would be nice to change dinamically the name of the table than to create a grid for each database view.

Kind regards,
Sorin
View profile  Send private message
morowind

Posts: 46
Posted: 08/12/2016, 4:20 AM

Sure,
Dynamically Modify the SQL Statement
Add the Before Build Select event to the Grid :
assuming you have PHP :

  
function Tasks_DataSource_BeforeExecuteSelect(& $sender) {  
   global $Tasks;    //your grid name  
   $Tasks->DataSource->SQL = "SELECT * FROM Tasks";    
}  

for dynamicaly change :

use link parameter like file.php?view=someview
than use it in before build select event:

  
function Tasks_DataSource_BeforeExecuteSelect(& $sender) {  
   global $Tasks;    //your grid name  
   $view = CCGetFromGet('view')  
   if($view == 'someview'){   
         $Tasks->DataSource->SQL = "SELECT * FROM ViewTable1";    
   }elseif(($view == 'someview2')){  
         $Tasks->DataSource->SQL = "SELECT * FROM ViewTable2";  
  }  
  ......  
}  

You can find this on help file under CodeCharge Studio Examples and Techniques
Happy coding! :)
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.