Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name of action column #150

Closed
dan-developer opened this issue Feb 26, 2017 · 5 comments
Closed

Name of action column #150

dan-developer opened this issue Feb 26, 2017 · 5 comments

Comments

@dan-developer
Copy link
Contributor

How to set a friendly name for the action column?

drop down action column

@kartik-v
Copy link
Owner

Set the header property of the action column to a string you need.

@dan-developer
Copy link
Contributor Author

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.

@githubjeka
Copy link

githubjeka commented Jul 26, 2017

Same too
[DELETED]
I can't get labels from Models,, need to copy to header colums. It's very very very bad..

@kartik-v
Copy link
Owner

kartik-v commented Jul 27, 2017

@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.

@githubjeka
Copy link

githubjeka commented Jul 27, 2017

Oh, sorry for this. I've got it all mixed up, your code correct.

I just thought of something that is not exist... REF yiisoft/yii2#4504 yiisoft/yii2#4738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants