PHP code example of lauwen / grid

1. Go to this page and download the library: Download lauwen/grid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lauwen / grid example snippets


php artisan vendor:publish --provider=Lauwen\Grid\GridServiceProvider

$grid->setSubGridTitle(["你的子列表标题", ...]);
$grid->setSubGridUrl(["请求的数据接口地址", ...]);    // la_id::get
$grid->setActionUrl(["保存数据的接口地址", ...]);    // la_data::post
$grid->setSubGridColumns([
    ["ID", "Name", "Price", "Quantity"],
    ...
]);  // 列标题
// 其中field为字段名,editable为该字段是否可编辑
$grid->setSubGridFields([
    [
        [
            "field"     =>  "id"
        ],
        [
            "field"     =>  "name"
        ],
        [
            "field"     =>  "price",
            "editable"  =>  true
        ],
        [
            "field"     =>  "quantity",
            "editable"  =>  true
        ],
        [
            "field"     =>  "specs"
        ],
        ...
    ],
    ...
]);    // 列字段名

或者


$grid->setSubGrid(function ($subGrid) {
    $subGrid->setSubGridTitle(["你的子列表标题", ...]);
    $subGrid->setSubGridUrl(["请求的数据接口地址", ...]);    // la_id::get
    $subGrid->setActionUrl(["保存数据的接口地址", ...]);    // la_data::post
    $subGrid->setSubGridColumns([
        ["ID", "Name", "Price", "Quantity"],
        ...
    ]);  // 列标题
    // 其中field为字段名,editable为该字段是否可编辑
    $subGrid->setSubGridFields([
        [
            [
                "field"     =>  "id"
            ],
            [
                "field"     =>  "name"
            ],
            [
                "field"     =>  "price",
                "editable"  =>  true
            ],
            [
                "field"     =>  "quantity",
                "editable"  =>  true
            ],
            [
                "field"     =>  "specs"
            ],
            ...
        ],
        [
            [
                "field"     =>  "id"
            ],
            [
                "field"     =>  "name"
            ],
            [
                "field"     =>  "price",
                "editable"  =>  true
            ],
            [
                "field"     =>  "quantity",
                "editable"  =>  true
            ],
            [
                "field"     =>  "specs"
            ],
            ...
        ]
    ]);    // 列字段名
});

$id = request()->get('la_id');

$id = request()->post('la_data');