What is preventing the invocation of a function from v-data-table?

I am struggling to figure out how to call the getName() function in order to change the table value. It appears that the function is not being called and the values are being directly fetched from the headers instead. Is there a way for me to change the value by properly calling getName()?

<v-data-table :headers="headers" :items="studies" :search="search" @click:row="detail">
        <template slot="items" slot-scope="props">
          <td>{{ props.item.title }}</td>
          <td>{{ getName(props.item.user) }}</td>
          <td>{{ props.item.createdAt }}</td>
        </template>
</v-data-table>
headers: [
      {
        text: 'Title',
        value: 'title',
        sortable: true
      },
      {
        text: 'Name',
        value: 'user',
        sortable: false
      },
      {
        text: 'Created',
        value: 'createdAt',
        sortable: false
      }
    ]
getName(val) {
      this.$axios.get("http://localhost:3000/users/" + val).then(res => {
           this.name = res.data.name;
         });
      console.log(this.name);
      return this.name;
    },

Answer №1

In the documentation for Vuetify, it is clearly mentioned that the click:row event will not be triggered when table rows are defined through slots such as item or body, like in the code example provided above. Refer to the link below to explore the events available for Vuetify's data table.

Link to Documentation

To address this, you can structure your table in the following manner and then add any custom methods or actions to the values if needed:

<v-data-table :headers="headers" :items="studies" :search="search" @click:row="detail">

  <template v-slot:item.title="{ item }">
    <v-chip>{{ item.title }}</v-chip>
  </template>

</v-data-table>

Ensure that the props are structured like this:

[
  {title: "Java 101", user:"anon_User", createdAt:"new Date()"},
  {title: "Vue3", user:"root_user", createdAt:"new Date(7)"},
]

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

Utilizing the Flex property on the parent div ensures that all child elements receive an equal width

I am currently working on a messaging application and I want the layout to be similar to Twitter or Whatsapp. Specifically, I want the messages from the person the user is chatting with to appear on the left side, while the user's own messages should ...

Avoid showing a pop-up window when switching to a different page

I have a pop-up window that displays a confirmation message only when I am trying to close the browser/tab. It is working on my page, but it also appears when I navigate to another page. I want the pop-up window to only show up when I try to close the ta ...

Preventing Users from Uploading Anything Other than PDFs with Vue

I am currently working with Bootstrap-Vue and Vue2. Utilizing the Form File Input, I want to enable users to upload files, but specifically in PDF format. To achieve this, I have included accept="application/pdf": <b-form-file v-model=&quo ...

JavaScript throws an error when attempting to access an object's methods and attributes

Within my Angular.js module, I have defined an object like this: $scope.Stack = function () { this.top = null; this.size = 0; }; However, when I try to use the push method of this object, I encounter an error stating undefined: ...

Having difficulty accessing a function within the SignalR connection function

I am currently facing an issue while trying to access a specific function within a SignalR connection function. Below is the code snippet showcasing the entire script for better understanding: $(function() { var chat = $.connection.chatHub; chat.c ...

A single parallax transition designed exclusively for you

I am looking to add a unique parallax transition to my website, specifically one that features a nice scroll followed by a subtle bounce effect. For example, I want to incorporate an arrow that, when clicked, smoothly scrolls the user to the bottom of th ...

Update the Ngrx reducer when the component is present on the page

One dilemma I am facing involves managing two components within a page - an update user form and a history of events. Each component has its own reducer (user and events). My goal is to update the list of events in the store through an API call once the us ...

Converting Persian calendar date to Gregorian in JavaScript

Looking for assistance in converting a date from 1379/10/02 to AD format, specifically to the date 2000/4/29 using the momentJs library. Any help with this task would be greatly appreciated. Thank you! ...

The mdSidenav service encounters difficulties locating a component within an Angular component

Trying to understand why an Angular .component(), which contains a <md-sidenav> directive, cannot be located from the component's controller. Angular throws the error message: No instance found for handle menu The complete component code is ...

Sending a document to a distant server using a background script in Thunderbird

I am currently working on a Thunderbird extension that has the ability to upload attached files in emails. The process flow of this extension is outlined below: Clicking on the extension icon will display a popup with options to select from: "Read All", " ...

What could be causing the invalid expression error to pop up in my Vue.js template?

I encountered an error within my vue single file component: Errors compiling template: invalid expression: Unexpected token { in {{ jobs[0].build_link }} Raw expression: v-bind:href="{{ jobs[0].build_link }}" The complete code causing the is ...

What sets server-side development apart from API creation?

As I dive into the world of web development, I find myself facing some confusion in my course material. The instructor has introduced concepts like promise objects and fetch, followed by axios, and now we're delving into the "express" package for buil ...

Error occurs when attempting to call JavaScript from the server-side code

When utilizing Page.ClientScript.RegisterStartupScript to invoke a JavaScript function from the code behind, everything works smoothly for simple functions in JavaScript. However, issues arise when the JavaScript function includes an object. For instance: ...

Learn the technique of looping through multiple HTML elements and wrapping them in Vue.js easily!

i need to wrap 2 HTML elements together Here is my code snippet using Vue.js <tr> <th v-for="(item9,index) in product_all" :key="item9.id"><center>Qty</center></th> <th v-for="(item99,index) in product_all" :key=" ...

The nested directive link function failed to execute and the controller was not recognized

Apologies in advance for adding to the sea of 'mah directive link function isn't called!' posts on Stack Overflow, but none of the solutions seem to work for me. I have a directive named sgMapHeader nested inside another directive called sg ...

Determine if a user has made any spelling errors within an HTML textarea using spellcheck

I am working with a textarea that has the following definition: <textarea spellcheck="true"></textarea> As users type, spelling mistakes are highlighted (such as with a red underline in my browser). Is there a way, possibly using jQuery, to v ...

Attempting to modify the color of a selected Three.js object causes all objects in the scene to have their colors altered

For example, check out this JSFiddle link. The interesting part occurs during the mousedown event: var hits = raycaster.intersectObjects( [object1, object2, object3] ); if ( hits.length > 0 ) { console.log(hits[ 0 ].object) hits[ 0 ].object.m ...

What is the most efficient way to query through a Firestore database containing 5,000 users?

We are currently facing a challenge with our staffing application, which is built using vuejs and a firestore database containing over 5,000 users. Our primary issue lies in the need for a more efficient layout that allows admins to search for users within ...

Are there any SVG libraries available that can create line graphs similar to those seen in Google Analytics?

The line graph in Google Analytics that is created using SVG is quite impressive. Are there any libraries available that can generate similar line graphs to those in Google Analytics? ...

Remove the container once all of its children have been dismissed

Is it possible to automatically remove the parent container when all of its children elements have been removed? Each child element has a dismissal option that, when clicked, removes the element. I am using backbone.js for this project and would like a so ...