public function provideEditableColumns(array &$fieldSpecs) { $fieldSpecs += array('StockLevel' => array('title' => 'In Stock', 'callback' => function ($record) { $inStock = 0; if ($stockLevel = StreakStockLevel::get()->byID($record->StreakStockLevelID)) { $inStock = $stockLevel->StockLevel; } return new NumericField('StockLevel', 'Stock level', $inStock); })); return true; }
/** * Called for each new row in a grid when it is saved. * * @param $record * @return bool */ public function gridSheetHandleNewRow(array &$record) { $updateData = $this->getUpdateColumns($this->owner->class, $record); $stockLevel = StreakStockLevel::create($updateData); $stockLevel->write(); }