Having trouble updating the vue bootstrap table after sending data from child to parent component

I have successfully implemented a slot for the header in vue-bootstrap, allowing me to add a show and hide button with a search box in each column header. The header is placed within a slot and the fields data includes a showFilter property that toggles between true and false. Although emitting data changes from the child component to the parent works fine, the table itself does not update until another action is triggered, like sorting a header. I attempted to force refresh the table data as mentioned in the documentation, but it did not seem to work or I could not understand how to implement it properly without an example.

Parent

<template>
<b-table
      ref="table"
      :items="filtered"
      :fields="fields"
      sort-icon-left
      responsive="sm"
    >
      <template v-slot:head()="data">
        <TableHeader :data="data" :filters="filters" />
      </template>
    </b-table>
</template>

data() {
  return {
      fields: [
        {
          key: "name",
          sortable: true,
          showFilters: true,
        },
        { key: "age", sortable: true, showFilters: true },
      ],
    }
}

Child

<template>
  <div>
    <div class="text-info">{{ data.label.toUpperCase() }}</div>
    <div>
      <button @click="setUpdate(data.field)">filters</button>
    </div>
    <input
      v-show="data.field.showFilters"
      v-model="filters[data.field.key]"
      :placeholder="data.label"
      @keyup="$emit('update:filters[data.field.key]')"
    />
  </div>
</template>

  methods: {
    setUpdate(field) {
      this._originalField = Object.assign({}, field);
      field.showFilters = !field.showFilters;
      this.$root.$emit("update:field.showFilters", "bv::refresh::table");
      console.log(field.showFilters);
    }
  }

Answer №1

My solution involved implementing a bootstrap collapse button and handling everything within the child component, which seems like a more logical approach!

   <b-collapse :id="'collapse' + data.field.key">
      <b-card>
        <!-- content -->
      </b-card>
    </b-collapse>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display the value in Vue.js as a price format while maintaining it as an integer

I have created a Vue component called "formatted-number" which takes in an integer value (e.g. 1234) and currently displays it as a string (e.g. "12.34") to represent a price in a textfield, with the appropriate "," or "." based on the country. However, I ...

Utilizing Vue Cli's Webpack Proxy feature

While working on a project using the vue-cli and the Webpack template, I am facing some difficulties with setting up a custom host. Currently, Webpack is listening to localhost:8080, but I need it to work with a custom domain like . Has anyone found a solu ...

Challenges in navigating routes with vue.js

Having some issues with my pages not displaying properly. I suspect it could be due to my routing setup. I am fairly new to this so any help would be appreciated. Here is a link to my project on GitHub: https://github.com/PietroSerra/order-login-master2 ...

Trouble encountered while attempting to choose a single checkbox from within a v-for loop in Vue.js?

<div id="example-1"> <ul> <input type="text" v-model="searchString" placeholder="Filter" /> <p>sortKey = {{sortKey}}</p> <li v-for="item in sortedItems"> <input class="checkbox-align" type="checkbo ...

Fix Vue by deleting "public" from the file path

After removing the "public" from the URL path following this guide Laravel 5 – Remove Public from URL, I have encountered an issue with Vue scripts not working properly. Interestingly, if you add "public" back to the path, the script works fine (http:// ...

Vue 3 - Cascading Property Updates throughout the Component Tree

I have a Vue 3 application set up in the following structure: +---------------------+ | Component | | +-----------------+ | | | Child Component | | | +-----------------+ | +---------------------+ The components are structured as follows: my-com ...

Creating a Copy of an Object in JavaScript that Automatically Updates When the Original is Changed

I am in the process of developing a planner/calendar website with a repeat feature. var chain = _.chain(state.items).filter({'id': 1}).head().value(); console.log(chain); After filtering one object, I am wondering how to create a duplicate of c ...

Prevent users from editing Dropdown List in Bootstrap Vue

I'm currently working on a project using "Bootstrap Vue" where I have implemented a feature that changes the input fields to readonly mode when the user clicks on the "confirm" button. This functionality is achieved through a boolean variable assigned ...

Components in Vue are not being displayed correctly when rendered in a separate blade file

Currently, I am in the process of developing a Laravel application with Vue.js. Although I am new to Vue.js and still learning, I have successfully implemented two interfaces within my application - one for admin panel and another for normal users. The cha ...

Ways to discreetly conceal forward and backward buttons in the v-pagination component of Vuetify

Is there a way to remove the previous and next buttons from v-pagination in Vuetify? Here's my code snippet- <v-pagination v-model="page" :length="pageCount" :total-visible="8" color="primary" /> ...

Could it be possible that my consecutive POST and GET axios requests are gradually slowing down?

After chaining the POST and GET calls in my code, I noticed a slight slowdown and was curious if this is normal or if there's a more efficient approach. The delay in displaying the google map marker made me think that pushing the newly created marker ...

Customizing CoreUI column names in Vue

I am working with an array of item objects for a table. For example: [{ name: 'Sam', age: 24 }] Instead of using the default column names like age, I want to set custom field names. For instance, I want to display the column as Id instead of age ...

[Vue-ChartJS] Seeking out instructions on incorporating gradients with Vuex and the reactiveProps mixin (API data) has proven challenging

Issue Link to Codepen example: https://codesandbox.io/s/vyy0z2my33 If you want to track this issue, visit: https://github.com/apertureless/vue-chartjs/issues/473 I have a project with a datepicker that triggers chart rerendering based on the selecte ...

During the compilation process, V8Js encountered an error (ReferenceError) on line 9272, specifying that the

<?php namespace App\Http\Controllers\Auth; use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; use Illuminate\Http\Request; use App\Http\Controllers\Contro ...

Is it possible for pdfjs-dist to be used with Typescript?

Is there a way to preview a PDF as a canvas without importing pdfjs-dist into my project? I have already used the command $yarn add pdfjs-dist to install pdfjs-dist. Do I need to include any additional imports? import pdfjsLib from "pdfjs-dist/build ...

Guide on applying CSS to option tag within a select element in VUE.js

I am attempting to design a dropdown menu that resembles the one shown in the image. However, I'm currently unable to include any CSS styling. Can anyone provide guidance on how to create a customizable select dropdown in Vue? https://i.stack.imgur.c ...

What might be causing my Vue unit test to overlook a function?

I am in the process of creating unit tests for my component dateFormat.js using Jest. The focus is on testing the function formatDateGlobal. Here is an excerpt from the test: import DateFormat from '../dateFormat'; describe('dateFormat.js& ...

What is the best way to customize the look of the v-calendar component in Vue.js?

I've recently started a project that involves Vue.js, and I needed to create a datepicker for it. After some research, I opted to utilize the v-calendar package. The implementation of the component went smoothly and functioned as expected right out o ...

Vue js for filtering and replacing prohibited words

For this scenario, our objective is to screen the words in our input: <input type="text" class="form-control" placeholder="Write something..." v-model="todoInput""> Below are the restricted words that we aim to substitute in the input "restrict ...

Obtaining the currentTarget object through a click event

When using Jquery to retrieve an object from the current target, it works perfectly. However, I would like to achieve the same behavior with VueJs, but VueJs returns a DOM instead of an object. Using Jquery <a onclick="test(this)" type="button"&g ...