DataGrid


ID Title Body Author Categories Edit
2 Article 2 Body... Jane Doe
4 Article 4 Body... Jane Doe
7 Article 7 Body... Jane Doe
8 Article 8 Body... Jane Doe
9 Article 9 Body... Jane Doe
10 Article 10 Body... Jane Doe
13 Article 13 Body... Jane Doe
14 Article 14 Body... Jane Doe
15 Article 15 Body... Jane Doe
20 Article 20 Body... Jane Doe Category 2, Category 3


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