question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selectable rows without row-clicked event

See original GitHub issue

Is your feature request related to a problem? Please describe…

I have a selectable table that when a row is clicked, it opens a modal with information about the row. I’m mainly handling the row selection with custom checkboxes that let you check/uncheck a row to select that row.

I’m leveraging the this.$refs.selectableTable selectRow and unselectRow methods to handle the selecting when the checkboxes are toggled.

The problem I’m running into is that clicking the row selects the row as well as opens the modal, which is not desirable in my application. I would like the row to only be selectable by the checkboxes I’ve added to the table.

Describe the solution you’d like

I would like to be able to use all of the functionality of the selectable table without the row-clicked event triggering selecting the row.

Describe alternatives you’ve considered

I’ve tried stopping the events on the row-clicked event, but by that point it’s too late to stop the emitter.

Additional context

Here is my table configuration right now:

<b-table
    ref="selectableTable"
    selectable
    @row-selected="onRowSelected"
    select-mode="multi"
    hover
    selected-variant="active"
    @row-clicked="openModal"
    :items="localItems"
    :fields="columns"
    responsive
    outlined
    :busy="loading"
    :filter="filters"
    :filter-function="filterInput"
    :show-empty="true"
>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
trouttdevcommented, Oct 4, 2019

Yep, that worked great. Thanks! If anyone comes across this in the future, this is what I did: Add :tbody-tr-class="determineActive" to your table and then add the method:

determineActive(item, type) {
    if (item && type == 'row') {
        if (this.selectedRows.some(row => row.id == item.id)) {
            return 'table-active';
        }
    }
},
0reactions
fuoridallaretecommented, Nov 28, 2019

Is there then a kind of work around to solve it? Sorry to bother…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent row click function on specific column in ...
The accepted answer works but there may be people looking to interact with the row and not the column clicked. For those cases...
Read more >
How to prevent row select during click event? - jQWidgets
The approach that I suggest you with unselectRow does not clear all selected rows. You could unselect only this row where you click....
Read more >
can not distinguish row click and row select event in ...
hi, i am using treegrid, In rowSelected event, i couldnt tell the difference between the user just click the row or select the...
Read more >
Row Selection - JavaScript Data Grid
Clicking multiple rows will select a range of rows without the need for Ctrl or Shift keys. Clicking a selected row will deselect...
Read more >
Select or Deselect Items on Row Click - Kendo UI Grid for jQuery
When selection is enabled in the Grid component, the built-in option for deselecting a row or selecting multiple rows is Ctrl + click....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found