DataGrid


ID Title Body Author Categories Edit
20 Article 20 Body... Jhon Doe Category 2, Category 3
19 Article 19 Body... Jane Doe
18 Article 18 Body... Jane Doe
17 Article 17 Body... Jhon Doe
16 Article 16 Body... Jhon Doe
15 Article 15 Body... Jane Doe
14 Article 14 Body... Jhon Doe
13 Article 13 Body... Jhon Doe
12 Article 12 Body... Jane Doe
11 Article 11 Body... Jane Doe


class DemoController extends Controller

....

    public function 
getGrid()
    {

        
$grid = \DataGrid::source(Article::with('author''categories'));

        
$grid->add('id','ID'true)->style("width:100px");
        
$grid->add('title','Title');
        
$grid->add('{!! str_limit($body,4) !!}','Body');
        
$grid->add('{{ $author->fullname }}','Author''author_id');
        
$grid->add('{{ implode(", ", $categories->lists("name")->all()) }}','Categories');

        
$grid->edit('/rapyd-demo/edit''Edit','show|modify');
        
$grid->link('/rapyd-demo/edit',"New Article""TR");
        
$grid->orderBy('id','desc');
        
$grid->paginate(10);

        
$grid->row(function ($row) {
           if (
$row->cell('id')->value == 20) {
               
$row->style("background-color:#CCFF66");
           } elseif (
$row->cell('id')->value 15) {
               
$row->cell('title')->style("font-weight:bold");
               
$row->style("color:#f00");
           }
        });

        return  
view('rapyd::demo.grid'compact('grid'));
    }



@extends('rapyd::demo.demo')

@section('title','DataGrid')

@section('body')

    <h1>DataGrid</h1>
    <p>

        {!! $grid !!}
        
        
    </p>
@stop