Closed Insolita closed 10 years ago
Do you have time for a pull request?
unfortunately, i can't soon
@Insolita Please, provide an example... I try to find out time to do it. I have something in mind but I would like to confirm is exactly what you request.
exapmle - what i want - in gridview
[
'attribute' => 'position',
'value' => function ($data) use ($positions) {
return $data->position ? $positions[$data->position] : Yii::t('app','Not set');
},
'filter' => $positions,
'class' => \dosamigos\grid\EditableColumn::className(),
'url' => ['/widgetman/widgetman/editable'],
'type' => 'select',
'editableOptions' => function ($data) use ($module) {
return [
'emptytext' =>Yii::t('app','Not set'),
/**
it`s return options for choose with object specific, don`t want use ajax query
**/
'source' => \yii\helpers\Json::encode($module->getWidgetPlaces($data->class))
];
}
],
so in your EditableColumn must be something like this
protected function renderDataCellContent($model, $key, $index)
{
$value = parent::renderDataCellContent($model, $key, $index);
if(is_callable($this->editableOptions)){
$opts=call_user_func($this->editableOptions, $model, $key, $index);
foreach ($opts as $prop => $v) {
$this->options['data-' . $prop] = $v; //Not sure about this
}
}elseif(is_array($this->editableOptions){
foreach ($this->editableOptions as $prop => $v) {
$this->options['data-' . $prop] = $v;
}
}
$url = (array)$this->url;
$this->options['data-url'] = Url::to($url);
$this->options['data-pk'] = $key;
$this->options['data-name'] = $this->attribute;
$this->options['data-type'] = $this->type;
return Html::a($value, null, $this->options);
}
Thanks a lot for attention
@Insolita looks good... checking your PR
closed by #10
please add ability to set EditableOptions by Closure