DataGrid


ID Title Body Author Categories Edit
2 Article 2 Body... Jhon Doe
3 Article 3 Body... Jhon Doe
4 Article 4 Body... Jhon Doe
5 Article 5 Body... Jhon Doe
9 Article 9 Body... Jhon Doe
11 Article 11 Body... Jhon Doe
12 Article 12 Body... Jhon Doe
14 Article 14 Body... Jhon Doe
15 Article 15 Body... Jhon Doe
18 Article 18 Body... Jhon 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