YII2 framework (iii) Extensions yii2-gird, yii2yii2-gird from scratch
The yii2-gird plug-in is an extension of Yii2.0. It provides some practical functions based on the official girdview.
For example:
Wrap the table under the bootstrap-panel label to make it more beautiful. The Float Header function makes it easy to view the table fields at the top of the screen when sliding the table. The operation bar label is added; page statistics function; new table reset function; new table export function, including four common formats: html, CSV, txt, Excel.
Thank you very much for the useful plug-ins provided by the Kartik team. Other plug-ins of the Kartik team are also useful. Trial is recommended.
Install yii2-grid
Use Composer for installation. Run the following command in windows cmd:
$ composer require kartik-v/yii2-grid "*"
Configure yii2-gird
The yii2-gird is a module and the configuration of the module needs to be added to the configuration file is as follows:
* Note:
\ Kartik \ gird \ Module configure the girdview Module path export/download configure the exported Action path for detailed instructions and Demo
Check the official documentation.
Http://demos.krajee.com/grid-demo
Click "Export" to return solution 404
When you click export for the first time, Error 404 cannot be found.
Click "Export" under analysis. The complete action path is index. php? = Module/export/download
Because my APP is modularized, there will be a module that calls the downloadAction method of the controller ExportController under the module.
The export Action path configured above is used here. Note that the default configuration of the plug-in is girdview/export/download.
You need to call the downloadAction method of the controller ExportController under the module girdview. If the APP is not multi-module, use the default configuration directly.
Therefore, copy the ExportController method under the plug-in to the module/Controllers/directory.
Click "Export" again. A window is displayed, prompting you to save the file.