Home > Article > Backend Development > Learn the YII2 framework from scratch (3) Extension plug-in yii2-gird, yii2yii2-gird_PHP tutorial
yii2-gird plug-in is an extension of Yii2.0. It extends some practical functions based on the official girdview.
For example:
把表格包装在bootstrap - panel标签下,使之更美观; Float Header功能,实现滑动表格的时候,表字段至于屏幕上方,方便查看; 新增操作栏说明label; 页面统计功能; 新增重置表格功能; 新增导出表格功能,包括四种常用格式[html、CSV、txt、Excel]。
Thank you very much to the Kartik team for the useful plug-in. Other plugins from the Kartik team are also very useful. Recommended to try.
Install yii2-grid
Use Composer to install, execute cmd command under windows:
$ composer require kartik-v/yii2-grid "*"
Configure yii2-gird
yii2-gird is a module. The module configuration needs to be added to the configuration file as follows:
*Instructions:
kartikgirdModule configures the path of the girdview module export/download configures the exported Action path detailed description and Demo
Just read the official documentation
http://demos.krajee.com/grid-demo
Click "Export" to return the solution to 404
When I clicked "Export" for the first time, a 404 error was reported. Interface not found.
After analysis, the action completion path when clicking "Export" is index.php?=module/export/download
Because my APP is modular, it will have a module, that is, calling the downloadAction method of the controller ExportController under the module module
The export Action path configured above is used here. It should be noted that the default configuration of the plug-in is girdview/export/download
What needs to be called is the downloadAction method of the controller ExportController under the module girdview. If the APP is not multi-module, just use the default configuration.
So here you need to copy the ExportController method under the plug-in to the module/Controllers/ directory
Click "Export" again, and a pop-up window will prompt you to save the file successfully.