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

Add target attribute to Magento_Ui grid #9964

Merged
merged 3 commits into from
Jun 20, 2017

Conversation

thelettuce
Copy link
Contributor

@thelettuce thelettuce commented Jun 16, 2017

When creating a Magento_Ui grid actionColumn, currently, it is not possible for links to have a target attribute. They can only open in the current browser tab ie. their target is always _self. This change expands that, allowing a target attribute to be added when using the prepareDataSource function of a custom Column module.

Description

added method getTarget to actions.js - it returns "_self" by default or the attribute set when using prepareDataSource.
added code to set link's target attribute to getTarget() in the actions.html template

Code example - when populating the column in a Magento_Ui grid, using a custom class to expand Magento\Ui\Component\Listing\Columns\Column, you can set the target attribute for the links created in your prepareDataSource function, as below.

$item[$name]['edit'] = [
    'href' => $this->_urlBuilder->getUrl(
                          $this->_editUrl,
                            ['id' => $item['id']]
                        ),
                        'label' => __('Edit'),
		'target' => "_blank"
];

Fixed Issues (if relevant)

Manual testing scenarios

  1. write module to create a Magento_Ui grid control
  2. modify the prepareDataSource function to add a target "_blank" attribute (as the example above)
  3. test grid by clicking on link

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@ishakhsuvarov ishakhsuvarov self-assigned this Jun 19, 2017
@ishakhsuvarov ishakhsuvarov added this to the June 2017 milestone Jun 19, 2017
@magento-team magento-team merged commit 4d26bd3 into magento:develop Jun 20, 2017
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

Successfully merging this pull request may close these issues.

3 participants