开发者

Get data from popup window to parent window in Magento

I am working on a Magento module that has a Form where a user has to enter a order number. So for this 开发者_开发知识库I have included a button in the form that opens a popup window that displays the list of orders.

Heres what i have done This is the code for the button that opens the popup

<button type="button" class="form-button" onclick="window.open(\''
.Mage::helper("adminhtml")->getUrl('*/inventory_receipt/selectOrder',array()
.'\',\'\',\'height=500,width=550\');"><span>'                               
.Mage::helper('adminhtml')->__('Lookup Order')
.'</span></button>

Then i have created a selectOrder Action in the controller that displays a grid that is almost similar to the grid in the sales/order (just modified Grid.php from sales/order).

Now what i want to implement is when the user clicks on an order, the parent form should be populated with the selected order number and close the popup window. Can any help on how to get this done? Any help would be appreciated.


You could use the javascript window.opener reference inside the popup to execute javascript in the original document.

But maybe it would be a better idea not to use an window.open popup but some kind of html layer.


Here is what I ended up doing. I Followed the steps over here, created an extra column with a button that populates the parent window. Code for the same is below

public function render(Varien_Object $row)
{
return '<button type="button" class="form-button" onclick="opener.document.getElementById(\'reference_id\').value='.$row->getIncrementId().'; window.close();"><span>'
            .Mage::helper('adminhtml')->__('Select Order')
            .'</span></button>';
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜