Integrating Grid++ Report Plugin into ThinkPHP5: A Step‑by‑Step Tutorial
This article walks through the complete process of integrating the Grid++ reporting plugin into a ThinkPHP5 project, covering environment setup, required JavaScript files, embedding the designer, controller implementation, and database configuration with clear code examples.
In order to use Grid++ for reporting within a ThinkPHP5 application, the author documented the integration process after finding limited resources online.
Environment : phpstudy, ThinkPHP5, Grid++ Report6.
1. Include required JavaScript files (placed in public/admin/js ):
<code><script type="text/javascript" src="__STATIC__/admin/js/GRInstall.js"></script></code> <code><script type="text/javascript" src="__STATIC__/admin/js/GRUtility.js"></script></code> <code><script type="text/javascript" src="__STATIC__/admin/js/CreateControl.js"></script></code>These three scripts constitute the Grid++ web‑side plugin.
2. Create the report in Grid++ : Follow the Grid++ UI to design the report; no additional code is required for this step.
3. Insert the designer plugin into a web page using the following script block:
<code><script type="text/javascript">
// Load report definition and data
CreateDisplayViewerEx("100%", "100%", "__STATIC__/grf/1a.grf", "__STATIC__/data/DataCenter.php?data=Student", true, "");
</script></code>4. Write the controller method to render the view:
<code>public function DisplayViewReport()
{
return $this->fetch();
}</code>5. Adjust database connection in Data/mysql_GenXmlData.php by setting mysql_connect() and mysql_select_db() to match your own MySQL server and database name.
The example is intentionally simple, avoiding multi‑table queries to illustrate the basic integration steps.
For further details and visual guidance, refer to the original article linked at the end of the page.
php中文网 Courses
php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.