Displaying rows in a dynamic table using a parameter within Vue.js

I am working with an Ant Design table in Vue that is rendered dynamically based on an API data response using

:data-source="table_deployenv_data"
:

<a-table :data-source="table_deployenv_data" :columns="columnsdeployenvs" bordered>
</a-table>

The columns are defined as follows:

columnsdeployenvs: [
        {
          title: "ID",
          dataIndex: "id",
          key: "id",
        },
        {
          title: "Env",
          dataIndex: "env",
          key: "env",
          scopedSlots: {
            filterDropdown: "filterDropdown",
            filterIcon: "filterIcon",
            customRender: "customRender",
          },
          onFilter: (value, record) =>
            record.env.toString()
              .toLowerCase()
              .includes(value.toLowerCase()),
          onFilterDropdownVisibleChange: (visible) => {
            if (visible) {
              setTimeout(() => {
                this.searchInput.focus();
              }, 0);
            }
          },
          sorter: (a, b) => a.modulename.localeCompare(b.moduleame),
          sortDirections: ["descend", "ascend"],
        },
        {
        .......

Currently, I have an 'env' parameter passed in as: {{ $route.params.id}} and I want to ONLY display the table rows where the value of the 'id' column equals {{ $route.params.id}}.

I have attempted using v-show and styling with display: none, but neither method seems to be working. Can anyone suggest a more elegant solution for achieving this? As someone new to frontend programming and Vue, any help would be greatly appreciated. Thanks!

Answer №1

Create a dynamic list

computed: {
  filteredTableData: {
    get: function () {
      return this.filteredTableData.filter(item=>item.id==$route.params.id);
    }



  
  }
}


<a-table :data-source="filteredTableData" :columns="columnsdeployenvs" bordered>
    </a-table>

Another Method

add the following in the data section

filteredTableData=[]

in the mounted method

this.filteredTableData = this.table_deployenv_data.filter(p=>p.id==this.$route.params.id);

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

Problem with Vue Router in Laravel subroute leading to incorrect component discovery

While I had a similar setup working smoothly on another Laravel/Vue project with the main route /, I encountered an issue when grouping the Vue instance under an admin subroute. All paths entered after "admin" would redirect to a PageNotFound component tha ...

Developing an SQL table for a website using JavaScript

My command is not functioning as expected and I am struggling to identify the issue. The database opens successfully, however, it fails to process the table creation. var createtable2 = 'CREATE TABLE IF NOT EXISTS offlineCabinDefects (id INTEGER PRIM ...

vue-router: display distinct views for the same route depending on the specified condition

We are exploring options to dynamically display different views based on the authentication status of a user, leveraging vue-router I am considering two potential approaches, although I am currently unsure of how to successfully implement either: Utilize ...

Resolving circular errors in ESLint with Prettier

I'm in the process of creating a Vue component. However, I've encountered an error: Type annotations can only be used in TypeScript files. If I remove the type clause, then I encounter: Missing return type on function. Here's how the comp ...

What is the best way to incorporate a dynamic background in NextJS using Tailwind?

I have a poster image that I want to use as a background image, fetched from MovieDb. I tried putting it inside the className like this: className={bg-[url('${path}')] h-screen bg-cover bg-center text-white border-b-8 border-b-solid border-b-sla ...

[ElectronJS][VueJs] ERROR_OSSL_EVP_UNSUPPORTED

I am in the process of developing an Electron app with VueJs. Currently, I am following a tutorial available at : https://www.youtube.com/watch?v=LnRCX074VfA However, I have encountered a bug and I am unsure about its meaning... Here is the error message ...

Anticipated request for spy navigation with path '/members' was expected, but unfortunately was not triggered

I am facing an issue with a service method that performs an HTTP delete operation. The expected behavior is that upon successful deletion, the page should be redirected to another location. However, during testing, I noticed that the router navigation func ...

What is the process of rotating a vector by 90 degrees to align it with a perpendicular plane, and then adjusting it further by 15 degrees out of

My ultimate objective is to determine a vector that represents the direction of the green line depicted in the image below, based solely on the positions of the yellow and green dots. To clarify, the angle of the vector can vary as long as its endpoint ...

What could be causing the Contact anchor element to not function properly?

I've been working on creating a dropdown menu for my API, but I'm having trouble getting the anchor links to function properly. I even attempted changing the "a" element to an onclick call with javascript:void(0) and added a function to open Gmai ...

Is it possible to toggle all parent targets in Bootstrap?

When trying to showcase my point, I believe it is best demonstrated by visiting Bootstrap documentation at https://getbootstrap.com/docs/4.0/components/collapse/ and viewing the "multiple targets section." In this section, you will find three buttons: togg ...

Sending numerous messages from a single event using Socket.io

After an exhaustive search, I have yet to find a solution to my problem. I am attempting to send a message from the server every time it detects a file change in a specific directory. However, instead of sending just one message, it sends the same message ...

How to transfer data from an HTML form to PHP using AJAX

I've encountered an issue while working on a simple application that consists of one HTML file communicating with a PHP page using AJAX. Take a look at my index.html below: <!DOCTYPE html> <html><head> <meta charset="utf-8"> & ...

Modify the button's color based on a separate column within the table

Currently, I am implementing Datatables along with X-editable and including some bootstrap buttons within a table. My objective is to change the color of the button in the 'Validated' column to green when the user updates the editable 'Statu ...

Utilizing JavaScript for simulating key presses on a webpage

Is it possible for a website to detect keystrokes and mouse movements? Can JavaScript be used to simulate actions, like clicking a mouse button, without physically doing so? If my question is unclear, please let me know. I'm new to this and feeling a ...

Tips for ensuring session token verification remains intact upon reloading

I am currently in the process of developing a website using the Next.js framework and I am seeking advice on how to prevent the reload effect that occurs when transitioning from the login page back to the main page for just a fraction of a second. Below i ...

What is the best way to adjust menu alignment for big screens?

Is there a way to set the alignment of a dropdown menu to the right specifically for large screens? <div class="btn-group"> <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expande ...

Is the security of Angular's REST authentication reliable?

My goal is to establish a secure connection with a REST service using Angular. I have come across the official method, which involves setting the authentication ticket like this: $httpProvider.defaults.headers.common['Authorization'] = 'dhf ...

Issue with aligning dropdown menu to the right in Bootstrap 5.1 not being resolved

I'm facing an issue with aligning my dropdown menu responsively on the right side of the page while keeping the "Create Event" button on the left. I followed the documentation which suggests adding .dropdown-menu-end to the ul class, but it didn' ...

Editing the object retrieved from JSON is not possible once it has been fetched

Project. Input text in the field and it appears on the shirt. When you click "see back," there is an issue where new text overlaps old text. Clicking on "see front" allows you to enter new text, with the previous text saved underneath. Question: How can ...

Mystery Surrounding MP3 Playback in ASP.NET

Currently, I am utilizing an ASP.NET server side control to play MP3 files on my website. While I could utilize JavaScript or Flash controls for this purpose, the issue I'm facing is that I want the music to only play once (at the start of the site) a ...