Steps to retrieve the value of a particular row in a table using vuejs

Can you help me retrieve the value of a specific row in a table using VueJS 2? Here is an image of my current table: https://i.sstatic.net/jb1uw.png

I need assistance with obtaining and displaying the last value from a loop in the "SHOW QR Button" within my code snippet. The button should dynamically showcase the final value returned by the loop.

<div class="myTable table-responsive">
  <table class="table">
    <thead class="thead-dark">
      <tr>
        <th>Member ID</th>
        <th>First Name</th>
        <th>Middle Name</th>
        <th>Last Name</th>
        <th>Address</th>
        <th>Actions</th>
      </tr>
    </thead>

    <tbody>
      <tr v-for="result in filteredList" :key="result.id">
        <td>{{result.Memb_ID}}</td>
        <th>{{result.First_Name}}</th>
        <th>{{result.Middle_Name}}</th>
        <th>{{result.Last_Name}}</th>
        <th>{{result.Address}}</th>

        <div class="row justify-content-center">
          <b-button v-b-modal.showDetails size="lg" class="showDetails" variant="danger">Edit</b-button>
          <b-button v-b-modal.modalQR size="lg" class="showQR" variant="success">Show QR</b-button>
        </div>
      </tr>
    </tbody>
  </table>
</div>

I am looking to have individual QR codes for each user, as shown in this modal: https://i.sstatic.net/XqiFP.png. Below is the representation for the "Show QR Button":

<b-modal id="modalQR" title="Generated Details">
    <div class="showQR text-center">
      <qrcode-vue :value="results.url" :size="size" level="H"></qrcode-vue>
    </div>
  </b-modal>

Additionally, here is the script that I am currently working with: https://i.sstatic.net/UxAMh.png

 <script>
import QrcodeVue from "qrcode.vue";
import axios from "axios";

export default {
  data() {
    return {
      search: "",
      results: {},
      value: "",
      size: 200,
      selected: [],
    };
  },
  computed: {
    filteredList() {
      return this.results.filter(post =>
        post.First_Name.toLowerCase().includes(this.search.toLowerCase())
      );
    }
  },
  methods: {
    getUsers() {
      axios
        .get("localhost:9000/user/")
        .then(response => (this.results = response.data))
        .catch(error => console.log(error.message));
    }
  },
  components: {
    QrcodeVue
  },
  mounted() {
    this.getUsers();
  }
};
</script>

Answer №1

v-for provides the item index as well:

<tr v-for="(result, index) in filteredList" :key="result.id">

You can then utilize index === filteredList.length

Answer №2

Here's a suggestion for you:

<tr v-for="result in filteredList.data" :key="result.id">
        <td>{{result.Memb_ID}}</td>

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

"Incorporating text input from a textbox into a <ul> list

Recently I started a new project which involves adding user-entered text from a textbox into a ul list in Bootstrap. The script for this functionality is placed within the head section of my HTML document. <script type="text/javascript"> fun ...

Redux - a method of updating state through actions

Hello, I am currently working on developing a lottery system and I have a question regarding the best approach to modify state using action payloads. Let's consider the initial state: type initialCartState = { productsFromPreviousSession: Product[ ...

Do watches operate asynchronously?

I am monitoring the status of a variable called radioStatus within a Vue instance: watch: { radioStatus: function(val) { if (!this.discovery) { $.ajax({ url: '/switch/api/radio/' + (val ? 'on' : 'off') }) ...

Arranging elements in two arrays in either ascending or descending order

Looking to implement sorting functionality for the "fuel.name" value within this array... const orders = [ { "_id":"5d14a31490fb1e0012a3d2d8-1", "orderId":"0JL5ORM0JT-1", "created":"2019-06-27T11:05:56.377Z", "createdDate":"2019-06-2 ...

Unable to utilize library post npm import

Recently, I attempted to integrate the flexibility library into my Laravel project. Following the installation with npm i flexibility --save, I required it in my app.js file: require('flexibility/flexibility.js'); ... flexibility(document.docume ...

The integration of <form> with jQuery Ajax error

I have come across this HTML form function FormSubmit (){ $.ajax({ url:'dotar.php', type:'post', data:$('form').serialize(), success:function(){ setTi ...

problem with passing the identification number into the function

I am facing an issue with passing the id into a javascript onClick method. I am using the Spring framework and in the controller class, I send the related id to the JSP file like this: model.addAttribute("uploadid", uploadid); Afterwards, I need to p ...

Exponential calculator in Javascript

I'm working on a basic calculator project using html5, css3 and javascript. However, I've run into an issue with the exponent button not functioning properly. Here's my code snippet: <html> <head> <meta charset = "utf-8" ...

Toggle visibility of various items in a to-do list, displaying only one item at a time with the use of JavaScript

I am currently working on a web project using the Laravel framework. I am struggling with implementing a feature where only the title of each to-do item is displayed, and when clicked, it should reveal the corresponding content. However, I have encountered ...

What steps can I take to display lines in a textarea so that it closely resembles the appearance of a notepad document

Is there a way to display lines in a text-area to give it the appearance of a notepad? I only have one text-area available. See the example notepad below for reference. ...

Caution: Updating a component is not possible during the rendering of another component. ReactJS

I am encountering an error in my ReactHooks/Typescript application with a Navigation component that renders a PatientInfo component. The PatientInfo component is conditionally rendered based on the props it receives, determined by a searchbox in another ch ...

Is it possible for Angular to retrieve information from one JSON file but not another?

After updating the names in the code to reflect the current ones, I would greatly appreciate any help or suggestions! The json file has been provided, so there's not much additional setup required. Just a heads up: I haven't created a service fi ...

Lustrous Layout

I am developing a mobile app using titanium where I have a scroll view containing objects that occupy 25% of the screen width. I am attempting to create a 'table' layout with these objects, having 4 columns and multiple rows. Is there a way for t ...

Is there a way to turn off the auto-complete feature for JavaScript keywords in HTML within JSX in WebStorm?

While using WebStorm, I've noticed that it automatically completes JavaScript keywords as I type regular text in JSX. This behavior is starting to frustrate me because I have to constantly press ESC or click elsewhere to hide the auto-complete popup. ...

TRPC fails to respond to the passed configuration or variables (e.g., when enabled is set to false)

Recently started using trpc and I'm trying to grasp how to utilize useQuery (which I've previously worked with in react-query): const IndexPage = () => { const { isLoading, data, isIdle } = trpc.useQuery([ "subscriber.add", { email: ...

The jQuery date picker is showing an error with the function daySettings[2].replace, indicating that

Encountering a problem with the jQuery version I am using: <script src="js/Common/jquery-2.1.1.min.js" type="text/javascript"></script> <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> The code I have writte ...

Present the value of an object within an array in an HTML format

I have organized an array containing information about different video games: let games = [{ title: 'Fortnite', price: 20, img: "./assets/images/Fortnite.jpg" }, { title: 'Valorant', price: 0, img: "./asse ...

Error encountered while attempting to send SendGrid email to multiple recipients

Currently, I am using const sgMail = require('@sendgrid/mail'); with sendgrid version 7.6.2. Whenever I attempt to add two email addresses in an array and then pass it into either send() or sendMultiple(), an error is being thrown like below. st ...

remove an element from a nested array using MongoDB

Greetings everyone! I am currently working on a materials document that contains arrays of articles, each article having an array of details. Here is a snippet from my collection data: { "_id": "62f2404b42556d62e2939466", "code&quo ...

Order of custom code and JQuery in ASP master page

Using an ASP master page to include all the Javascript and jQuery files has presented a challenge for me. Specifically, the jQuery function in OrderManagement.js $(".menu-item").click(function () { window.alert("some text"); }); fails to execute whe ...