PHP code example of shieldfroce / datatable

1. Go to this page and download the library: Download shieldfroce/datatable 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/ */

    

shieldfroce / datatable example snippets


 echo \Shieldforce\Frontend\CssRender\Ghost::head() 

 echo \Shieldforce\Frontend\JsRender\Ghost::js() 

 echo \Shieldforce\Frontend\JsRender\GhostExecution::js("server.php") 

$list = [];
for ($i=1;$i<=50000;$i++) {
    $age = rand(10, 80);
    $list[$i] = ["id"=>"{$i}", "name"=>"Firstname Lastname {$i}", "age"=>"{$age}"];
}

echo \Shieldforce\Backend\DatatableReturn::baseReturn($_POST, $list, function ($nestedData, $col, $r){

    // Configura as colunas de retorno com opção de criar lógica customizada!
    
    if($col=="id") {
        $nestedData["$col"] = $r["id"] ?? "-";
    } elseif($col=="name") {
        $nestedData["$col"] = $r["name"] ?? "-";
    } elseif($col=="age") {
        $nestedData["$col"] = $r["age"] ?? "-";
    } elseif($col=="action") {
        $nestedData["$col"]   = "-";
    } else {
        $nestedData["$col"] = "-";
    }

    // Retorna as colunas de resultado
    
    return $nestedData;
});