DataGrid


ID Title Body Author Categories Edit
7 Article 7 Body... Jane Doe
8 Article 8 Body... Jane Doe
9 Article 9 Body... Jane Doe
11 Article 11 Body... Jane Doe
12 Article 12 Body... Jane Doe
13 Article 13 Body... Jane Doe
15 Article 15 Body... Jane Doe
16 Article 16 Body... Jane Doe
17 Article 17 Body... Jane Doe
18 Article 18 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->pluck("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