Table->onRowClick() - Ignore click on checkboxes
Table->onRowClick() should not execute its action when a checkbox gets checked or unchecked.
@acicovic please provide simple steps to replicate, if you know how to fix it, please submit a PR
No time for this unfortunately. I will ping @ibelar, I think it would be simple for him to see if this issue is still a thing.
This is the function I had made up to get the correct selector. This mainly excluded the checkbox column and action menu.
protected function generateRowClickSelector($class = 'handle-row-click')
{
$this->table->addClass("{$class} selectable");
$excludeColumns = [];
if (!empty($this->selection)) {
$excludeColumns[] = ':first-child';
}
if (!empty($this->actionMenu)) {
$excludeColumns[] = ':last-child';
}
$selector = "table.{$class} tr td";
if (!empty($excludeColumns)) {
$selector .= ":not('".implode(',', $excludeColumns)."')";
}
return $selector;
}
And an example of how I used it:
/**
* Executes model User Action when row is clicked.
*/
protected function executeUserActionOnRowClick(string $action): void
{
$selector = $this->generateRowClickSelector();
$this->on('click', $selector, $this->model->getUserAction($action), [
$this->table->jsRow()->data('id'),
]);
}
This was done on a class overriding Grid.
Hope that helps.
Fixed by #1655
@mkrecek234 when some PR fixes some issue, the issue is closed by that PR when merged, no need to close it before...
This is a duplicate issue so no need to keep this topic open twice.
where is the 2nd one?
the PR says it fixes this one...
You are right, I had erroneously memorised the PR discussion as an issue. Reopening until you contribute the test😉