Magento adminhtml网格和javascript操作列 [英] Magento adminhtml grid with javascript action column

查看:47
本文介绍了Magento adminhtml网格和javascript操作列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于自己的模型设计自定义adminhtml网格,我在网格中添加了一个action列,希望能够单击以将一些文本复制到剪贴板.

I'm designing a custom adminhtml grid based on a model of my own, I've added an actions column to the grid which I'd like to be able to click to copy some text to the clipboard.

因此,在Grid.php的_prepareColumns()函数中,我添加了action列,如下所示:

So in the _prepareColumns() function in Grid.php, I've added the actions column as seen below:

$this->addColumn('action',array(
            'header'    => Mage::helper('sales')->__('To Clipboard'),
            'width'     => '5%',
            'type'      => 'action',
            'getter'     => 'getId',
            'actions'   => array(
                    array(
                        'caption' => Mage::helper('sales')->__('Copy'),
                        'url'     => array('base'=>'*/*/toclipboard'),
                        'field'   => 'id'
                    )
                ),
            'filter'    => false,
            'sortable'  => false,
            'is_system' => true,
        )
    );

我可能需要使用Javascript来执行此操作,但是我不确定如何执行此操作.即使我已经成功地将$this->setUseAjax(true);添加到了__construct();,使用上述方法的奇怪程度也足以导致页面重新加载.

I'd likely need to use Javascript to do this, but I'm not quite sure how to. Using the method above strangely enough also causes a page reload, even though I have successfully added $this->setUseAjax(true); to __construct();.

将感谢您的投入.

推荐答案

@Franklin P Strube:是的,向我指出了正确的方向.

@Franklin P Strube: ty, pointed me in the right direction.

我使用的最终解决方案如下

Final solution I used was as follows

 ....
          'actions'    => array(
                    array(
                    'caption' => Mage::helper('sales')->__('Copy'),
                    'onclick' => "javaScriptCopyMethod();"
                )
           ),
....

访问用户剪贴板被认为是一种不好的做法,如今大多数浏览器都阻止了此操作,但是我确实找到了一个非常有创意的帖子,链接如下,解释了Trello如何出现"以访问用户剪贴板,该解决方案实际上是由Daniel发布的LeCheminant是Trello开发人员之一.

It is considered bad practice to access a user's clipboard and most browsers prevent this nowadays, I did however find an extremely creative post linked below explaining how Trello "appears" to access the users' clipboard, the solution was actually posted by Daniel LeCheminant who is one of the Trello developers.

解决方案: Trello如何访问用户剪贴板?
附加: https://trello.com/daniel

Solution: How does Trello access the user's clipboard?
Additional: https://trello.com/daniel

这篇关于Magento adminhtml网格和javascript操作列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆