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.

Is column/cell exclusion of @row-clicked event on b-table possible ?

See original GitHub issue

Hi everyone,

I have a b-table (to display a list of records of course) in which I use the @row-clicked event to open the form view of the clicked record. I also use a column with b-form-checkbox to be able to select several lines (because selectable prop can’t be used aside of my event since my event switches to another component).

The thing is the checkbox is quite small and sometimes when I want to tick it I click outside of it, so on the row, and it triggers my event.

image

It would be very great to have a way to say : exclude these columns (for instance here the one with the checkboxes and the Actions column)

Since we have a way to define fields in a b-table with :fields, that I use like this :

  table_fields: [
    { key: 'selected' },
    { key: 'username', sortable: true },
    { key: 'firstName', sortable: true },
    { key: 'lastName', sortable: true },
    { key: 'groupIds', label: 'Groups' },
    { key: 'isActive', sortable: true, label: 'Status' },
    { key: 'actions', label: 'Actions' }
  ],

Would it be possible to implement a prop (like sortable) like exclude-from-rowclick or something like that ?

That would end up with something like :

  table_fields: [
    { key: 'selected', exclude-from-rowclick: true },
    { key: 'username', sortable: true },
    { key: 'firstName', sortable: true },
    { key: 'lastName', sortable: true },
    { key: 'groupIds', label: 'Groups' },
    { key: 'isActive', sortable: true, label: 'Status' },
    { key: 'actions', label: 'Actions', exclude-from-rowclick: true }
  ],

Maybe that already exists ? But I didn’t find it.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Hiwscommented, Mar 3, 2020

You could set a class on the cell (field) that sets padding to 0 (i.e. class p-0), and then render a div in the cell that has width and height set to 100% (classes w-100 and h-100, and add classes d-flex and align-items-center and justify-items-center to center the checkbox vertically and horizontally) and then add @click.stop on the div to prevent the click from bubbling up.

That’s pretty much exactly what i did in the codepen i posted above

1reaction
Hiwscommented, Feb 28, 2020

Here’s a codepen with a working example of what you could do to get this behavior.

By filling the cell with a div that has @click.stop, clicking the div wont trigger the @row-clicked event, while leaving the checkbox as is.

https://codepen.io/Hiws/pen/eYNWLEb

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude single column in row event - javascript - Stack Overflow
Example: I have five columns, I only want that row event to span 4 of those columns and not the last one. const...
Read more >
Disabling "RowClick" for one column in a grid - Telerik Forums
The RowClick event is not fired when you click on a control within a table cell in the grid. Am I missing something....
Read more >
Filter by values in a column - Power Query - Microsoft Learn
In Power Query, you can include or exclude rows according to a specific value by using any of the filter commands in a...
Read more >
FILTER() - AppSheet Help - Google Support
Select rows of table or sliceReturns select rows of table or slice as a list of Refs. ... reference the external column using...
Read more >
Jspreadsheet method and events - Bossanova
Before a new column is inserted. You can cancel the insert event by returning false. ondeletecolumn, After a column is excluded. onbeforedeletecolumn, Before...
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