Example #1
0
 public function demo14()
 {
     $this->prepareTiming();
     if (isset($_GET['details'])) {
         // mark resources as already included
         $manager = Services::resourceManager();
         $manager->js('jquery');
         $manager->js('bootstrap');
         $manager->css('bootstrap');
         return $this->demo14Details();
     }
     $grid = new Grid($provider = $this->getDataProvider(), [new Column('id'), new Column('name'), (new Column('age'))->setValueCalculator(function ($row) {
         return DateTime::createFromFormat('Y-m-d', $row->birthday)->diff(new DateTime('now'))->y;
     })->setValueFormatter(function ($val) {
         return "{$val} years";
     }), new AjaxDetailsRow(function ($row) {
         return "/index.php/demo14?details=1&id=" . $row->id;
     }), new PageTotalsRow(['id' => PageTotalsRow::OPERATION_IGNORE, 'age' => PageTotalsRow::OPERATION_AVG])]);
     $grid->attachTo($this->layout());
     $styling = new BootstrapStyling();
     $styling->apply($this->layout());
     $this->defaultCss->detach();
     return $this->page(null, 'AjaxDetailsRow (Click table rows to check)');
 }