protected function checkOutput() { $out = strtolower($this->grid->render()); self::assertTrue(substr_count($out, 'tr') >= DefaultFixture::getTotalCount() * 2); self::assertTrue(substr_count($out, 'td') >= DefaultFixture::getTotalCount() * 2 * 2); self::assertContains('form', $out); }
protected function replaceGridDataInjector(Grid $grid) { /** @var CollectionView $collectionView */ $grid->getCollectionView()->setDataInjector(function ($dataRow) use($grid) { $grid->setCurrentRow($dataRow); $this->processCurrentRow(); }); }
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)'); }