Closed dan-developer closed 7 years ago
Set the header
property of the action column to a string you need.
In this part of the code the column label is defined from the configuration array:
protected function getColumnLabel($key, $column)
{
if (is_string($column)) {
$matches = $this->matchColumnString($column);
$attribute = $matches[1];
if (isset($matches[5])) {
return $matches[5];
} //header specified is in the format "attribute:format:label"
return $this->getAttributeLabel($attribute);
} else {
$label = $key;
if (is_array($column)) {
if (!empty($column['label'])) {
$label = $column['label'];
} elseif (!empty($column['header'])) {
$label = $column['header'];
} elseif (!empty($column['attribute'])) {
$label = $this->getAttributeLabel($column['attribute']);
} elseif (!empty($column['class'])) {
$class = explode("\\", $column['class']);
$label = Inflector::camel2words(end($class));
}
}
return trim(strip_tags(str_replace(['<br>', '<br/>'], ' ', $label)));
}
}
This does not allow, for example, a dependency injection because the column is not instantiated before defining the label, for example:
\Yii::$container->set('tubaron\grid\DropDownActionColumn', [
'dropdown' => true,
'dropdownOptions' => [
'class' => 'pull-right',
],
'template' => '{view} {update}',
'header' => Yii::t('tubaron', 'Ações'),
]);
It may not be a crucial thing, but it might make things more centralized, so it would be great if you had events in DynaGrid like EVENT_BEFORE_INIT, EVENT_AFTER_INIT, etc ... It's a suggestion.
Thank you.
Same too
[DELETED]
I can't get labels from Models,, need to copy to header
colums. It's very very very bad..
@githubjeka would appreciate if you can share details of any issue and what your proposal is to overcome it in this extension, rather than just a critical remark from your end which is of no use or help.
@AndersonDan will need to study, understand and look into your proposed suggestion. Thanks for the suggestion.
Oh, sorry for this. I've got it all mixed up, your code correct.
I just thought of something that is not exist... REF https://github.com/yiisoft/yii2/issues/4504 https://github.com/yiisoft/yii2/pull/4738
How to set a friendly name for the action column?