1

I have form grid with selectbox in grid. so i would like to make row unclickable because when i try to click on select box it trigger checkbox too.

Screencast

any help would be very appreciate.

3
  • in which magento version? Feb 14, 2017 at 5:17
  • magento version 1.8
    – MageLerner
    Feb 14, 2017 at 5:20
  • you can try the answer given in grid.php Feb 14, 2017 at 5:24

4 Answers 4

1

This is how i achieve this.

This is my grid constructor and code is as below.it will stop fire onrowclick event on selectbox click.

public function __construct()
{
    parent::__construct();
    $this->setId('customerGrid');
    $this->setUseAjax(true); // Using ajax grid is important
    $this->setDefaultSort('id');
    $this->setDefaultFilter(array('customer_ids'=>1)); // By default we have added a filter for the rows, that in_products value to be 1
    $this->setSaveParametersInSession(false);  //Dont save paramters in session or else it creates problems
    $this->setAdditionalJavaScript("
    // added click on selectbox support
    serializerController.prototype.rowClick = serializerController.prototype.rowClick.wrap(function(o, grid, event) {
        var tagName = Event.element(event).tagName
            isSelect = (tagName == 'SELECT' || tagName == 'OPTION');
        if (!isSelect) {
            o(grid, event);
        }
    });
    ");
}
0

Please use the following code in grid.php for magento 1.x.x:

public function getRowUrl($row)
{
    return false;
}
4
  • This will remove url or not remove click event
    – MageLerner
    Feb 14, 2017 at 5:27
  • 1
    click event is coming because of the row url , so if you want to remove click event, you have to remove row url. Feb 14, 2017 at 5:31
  • I did but nothing was changed :(
    – MageLerner
    Feb 14, 2017 at 5:40
  • clear cache and try. Feb 14, 2017 at 5:45
0

By adding the following method

getRowClickCallback

to my grid class (that overrides a core grid Mage_Adminhtml_Block_Catalog_Product_Grid), that returns some fake JS function, like this

public function getRowClickCallback()
{
    return 'fakeJsFunction';
}

And this can help you in achieving your requirement

0

If you will not pass "rowUrl" function in argument, In grid section Row URL will not be set.

<block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.promo.quote.grid.columnSet">
    <!--<arguments>
         <argument name="rowUrl" xsi:type="array">
            <item name="path" xsi:type="string">ezerus_shippingreport/*/*</item>
            <item name="extraParamsTemplate" xsi:type="array">
                <item name="id" xsi:type="string">getId</item>
            </item>
        </argument> 
    </arguments>-->
    <block class="Magento\Backend\Block\Widget\Grid\Column" as="entity_id">
        <arguments>
            <argument name="header" xsi:type="string" translate="true">ID</argument>
            <argument name="index" xsi:type="string">entity_id</argument>
            <argument name="column_css_class" xsi:type="string">col-id</argument>
            <argument name="header_css_class" xsi:type="string">col-id</argument>
        </arguments>
    </block>                        
</block>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.