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.

Checkbox not updating when used in table header slot.

See original GitHub issue

I have been attempting to add a 3 state (true, false, intermediate) checkbox to the header of a table which ties in with each rows individual checkboxes. I am able to calculate and update the state of the checkbox and render it as I would like using a calculated function with getter and setter, however the checkbox within the header doesn’t render correctly. I have tried simplifying the checkbox within the header and found that it still doesn’t work. Here’s some example code:

<b-table :items="items" :fields="fields" :filter="filter">
  <template slot="HEAD_selected" scope="data">
    <input type="checkbox" v-model="allSelected"> {{allSelected}}
  </template>
  <template slot="selected" scope="entry">
    <input type="checkbox" v-model="allSelected">
  </template>
</b-table>

In this example, the table contains a column for ‘selected’ The header contains a checkbox bound to ‘allSelected’ along with an output of the ‘allSelected’ variable, and each row also has a checkbox bound to ‘allSelected’. Clicking the header checkbox updates the ‘allSelected’ variable, and the checkbox in every row updates accordingly, however the checkbox in the header remains unchanged. Clicking the checkbox again does nothing, as if the checkbox itself is still in its previous state. Clicking any of the checkboxes in the rows updates all checkboxes including the one in the header.

I have tried this with a standard checkbox, like the example above, and using the Bootstrap Vue b-form-checkbox.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:27 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
tmorehousecommented, Jul 21, 2017

When checkboxes are bound to the same v-model, they typically return an array to the v-model, with a value for each checked checkbox.

You probably need two variables, one for the check all, and one for the rows.

Check out this fiddle which is using checkboxes for select individual and select all…

https://jsfiddle.net/bootstrapvue/js5dqnjv/

image

1reaction
mauriciojsolacommented, Aug 24, 2020

Hi, why the checkboxes are no longer rendering as “checkboxes”? I have the same issue when using code like this:

<template slot="ProductSelection" slot-scope="row">
              <b-form-checkbox
                v-model="row.IsSelected"
                @input="onPreviewClick($event, row.index, row.item)"
              ></b-form-checkbox>
            </template>

https://jsfiddle.net/js5dqnjv/75/

Thanks!

vue-ckeckbox not rendeing

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap-vue issues with checkboxes in b-table
The checkboxes that are being rendered for each row in the "selected" slot are not binding to the correct row.
Read more >
Header check box selection of rows using ojet 7.2.0
Hi, We are using Ojet 7.2.0. We have check box to select rows in ojet table. header checkbox selection (ie select All) is...
Read more >
<th>: The Table Header element - HTML - MDN Web Docs
This attribute is used to shift column data to the right of the character specified by the char attribute. Its value specifies the...
Read more >
[Solved] QTable selection option not working when slots are ...
It has the same issue. The header has an extra blank element on the left, and there are no checkboxes.
Read more >
Checkbox component - Vuetify
A simpler version, v-simple-checkbox is used primarily as a lightweight alternative in data-table components to select rows or display ...
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