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.
any help would be very appreciate.
-
in which magento version?Prasanta Hatui– Prasanta Hatui2017年02月14日 05:17:30 +00:00Commented Feb 14, 2017 at 5:17
-
magento version 1.8MageLerner– MageLerner2017年02月14日 05:20:21 +00:00Commented Feb 14, 2017 at 5:20
-
you can try the answer given in grid.phpPrasanta Hatui– Prasanta Hatui2017年02月14日 05:24:21 +00:00Commented Feb 14, 2017 at 5:24
4 Answers 4
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);
}
});
");
}
-
Solved for me, thanks!Matheus Delazeri– Matheus Delazeri2023年12月28日 03:25:18 +00:00Commented Dec 28, 2023 at 3:25
Please use the following code in grid.php for magento 1.x.x:
public function getRowUrl($row)
{
return false;
}
-
This will remove url or not remove click eventMageLerner– MageLerner2017年02月14日 05:27:57 +00:00Commented Feb 14, 2017 at 5:27
-
1click event is coming because of the row url , so if you want to remove click event, you have to remove row url.Prasanta Hatui– Prasanta Hatui2017年02月14日 05:31:08 +00:00Commented Feb 14, 2017 at 5:31
-
I did but nothing was changed :(MageLerner– MageLerner2017年02月14日 05:40:05 +00:00Commented Feb 14, 2017 at 5:40
-
clear cache and try.Prasanta Hatui– Prasanta Hatui2017年02月14日 05:45:25 +00:00Commented Feb 14, 2017 at 5:45
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
-
This "works" but breaks any other javascript on the row such as serializer etc.HenryHayes– HenryHayes2024年09月23日 15:39:44 +00:00Commented Sep 23, 2024 at 15:39
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>