protected function setClientSideOptions()
{
$options = $this->grid->getClientSideOptions();
if (!isset($options['editable'])) {
//only once
$this->grid->setClientSideOptions(['editable' => TRUE]);
$this->grid->onRender[] = function (\Grido\Grid $grid) {
foreach ($grid->getComponent(Column::ID)->getComponents() as $column) {
if (!$column instanceof Editable || !$column->isEditable()) {
continue;
}
$colDb = $column->getColumn();
$colName = $column->getName();
$isMissing = function ($method) use($grid) {
return $grid->model instanceof \Grido\DataSources\Model ? !method_exists($grid->model->dataSource, $method) : TRUE;
};
if ($column->editableCallback === NULL && (!is_string($colDb) || strpos($colDb, '.')) || $column->editableCallback === NULL && $isMissing('update')) {
$msg = "Column '{$colName}' has error: You must define callback via setEditableCallback().";
throw new Exception($msg);
}
if ($column->editableRowCallback === NULL && $column->customRender && $isMissing('getRow')) {
$msg = "Column '{$colName}' has error: You must define callback via setEditableRowCallback().";
throw new Exception($msg);
}
}
};
}
}