Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox in datatable throwing js console error #96

Closed
HDShabe opened this issue Dec 9, 2021 · 1 comment
Closed

Checkbox in datatable throwing js console error #96

HDShabe opened this issue Dec 9, 2021 · 1 comment

Comments

@HDShabe
Copy link

HDShabe commented Dec 9, 2021

Hi,

I've got a datatable which has a checkbox as one of it's columns (or multiple columns with a checkbox in this example, though the same happens with just 1 column with a checkbox. Here's a simplified version:

<ui-table :data="requestData"
                      :thead="thead"
                      :tbody="tbody"
                      show-progress
                      fullwidth>
  
  <template #enabled="{ data }">
      <ui-checkbox v-model="data.enabled"></ui-checkbox>
  </template>
  
  <template #selectToAdd="{ data }">
      <ui-checkbox v-model="data.add"></ui-checkbox>
  </template>
</ui-table>



data:


thead: [
  {
      value: 'ID',
      sort: 'asc',
      columnId: 'id'
  },
  'Enable',
  'Add'
  ],
  tbody: [
    'id'
    {
        slot: 'enabled'
    },
    {
        slot: 'selectToAdd'
    },
],
requestData: [],

When I select one of the checkboxes, I see the following error in console:

balm-ui.esm.js:1 Uncaught TypeError: Cannot read properties of undefined (reading '0')
at Object.isCheckboxAtRowIndexChecked (balm-ui.esm.js:1)
at e.handleRowCheckboxChange (balm-ui.esm.js:1)
at HTMLTableSectionElement.handleRowCheckboxChange (balm-ui.esm.js:1)

However, if I add the row-checkbox property onto the data-table, like so:

<ui-table :data="requestData"
                      :thead="thead"
                      :tbody="tbody"
                      show-progress
                      row-checkbox
                      fullwidth>

The error now goes away, though i'm left with a set of checkboxes on the left of the datatable which I don't want.

I'm assuming this is a bug, can it be resolved?

Cheers.

@elf-mouse
Copy link
Member

Thanks @HDShabe ,

It's a MDC(@material-components) official bug, I have fixed now.

You can reinstall new version and enjoy it.

<ui-table :data="requestData" :thead="thead" :tbody="tbody" fullwidth>
  <template #enabled="{ data }">
    <ui-radio v-model="enabled" :value="data.value"></ui-radio>
  </template>

  <template #selectToAdd="{ data }">
    <ui-checkbox v-model="add" :value="data.value"></ui-checkbox>
  </template>
</ui-table>
export default {
  data() {
    return {
      thead: [
        {
          value: 'ID',
          sort: 'asc',
          columnId: 'id'
        },
        'Enable',
        'Add'
      ],
      tbody: [
        'id',
        {
          slot: 'enabled'
        },
        {
          slot: 'selectToAdd'
        }
      ],
      requestData: [
        {
          id: 1,
          value: 'a'
        },
        {
          id: 2,
          value: 'b'
        }
      ],
      enabled: 'a',
      add: ['a', 'b']
    };
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants