The search feature is currently malfunctioning due to an issue with the array in Vue and Vuetify's v-data-table component

Issues with searching by phone array.

While creating a table on Vuetify, I encountered an issue - the search functionality does not work when trying to search by an array. I am struggling to find a solution to this problem. Any assistance would be greatly appreciated.

Template:

<div id="app">
  <v-app>
    <v-card>
       <v-card-title>
         <!-- Search form -->
         <v-text-field
            v-model="search"
            append-icon="mdi-magnify"
            label="Search"
            single-line
            hide-details
         ></v-text-field>
      </v-card-title>
      <v-data-table
         :headers="headers"
         :items="items"
         :search="search"
      >
        <template #item="{ item }">
          <tr>
            <td>{{ item.name }}</td>
            <td>{{ item.adress }}</td>
            <td>
              <p v-for="(phone, key) in item.phones" :key="key">
                {{ phone.value }}
              </p>
            </td>
          </tr>
        </template>
      <v-data-table>
    </v-card>
   </v-app>
</div>

Script:

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data() {
    return {
      search: '',
      headers: [
        {
          text: 'name',
          value: 'name'
        },
        {
          text: 'address',
          value: 'address' 
        },
        {
          text: 'phones',
          value: 'phones'
        }
      ],
      items: [
        { 
          "name": 'John',
          "adress": 'took 1',
          "phones": [
            {
              'value': '32323223232'
            },
            {
              'value': '4343434343434'
            },
            {
              'value': '54545454545454'
            },
          ]
        }
      ]
    }
  }
})

Code: https://codepen.io/dev-sera/pen/OJRyPYp?editors=1111

p.s. I came across a similar issue but unsure how to implement the suggested solution for a numbered array -https://stackoverflow.com/questions/52845201/local-search-v-data-table-vuetify

Answer №1

update the phones array to

"phones": ['32323223232','4343434343434','54545454545454']
and modify your template like this
<p v-for="(phone, key) in item.phones" :key="key">{{ phone }}</p>
for it to function correctly.

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

JS - What is causing my JavaScript src to not work properly?

Here is a snippet of my code: <form name="calculator"> <input type="button" name="latest" value="You are not using the latest version."> <script src="http://www.alvinneo.com/bulbuleatsfood.js"> if(latest-version==="1.0.4.2"){ document.ca ...

Retrieve the truncated text content from the text node using ellipsis

Is there a way to retrieve truncated text from a node using Javascript? Take a look at the code snippet below: console.log(document.getElementById("text1").textContent); // prints "This is a long text" console.log(document.getElementById("text2").text ...

Warning: React has reached the maximum update depth limit

I am currently developing a D3 chart using React. Within my chart, I have integrated a brush component that interacts with React Hooks. Here is the snippet of code I am working with: App.js import React, {useEffect, useState} from 'react'; impo ...

Incorporating an SVG file within an img tag

In my ASP.NET mvc4 application, I have stored .svg files in the /content/Images folder. I am facing an issue while trying to use a .svg file as the src attribute under the <img> tag. It doesn't seem to work, even though inline svg works fine. H ...

Move the Vite build files to a different directory post-build

I currently have multiple Vue projects alongside a Wordpress project. One of the Vue projects is built with Webpack, while the other one is built with Vite. The folder structure is as follows: project | |__vue-project-webpack | | | |__dist | ...

Using TypeScript to define a generic type for the key in a React select component

Check out this component that wraps a Material UI select: return ( <Box display="flex" justifyContent={justifyContent}> <SortWrapper> <InputLabel htmlFor={id} shrink={true} > Sort by </InputLabel& ...

"Experience the power of Angular.js through seamless animations created by blending the capabilities

I want to smoothly fade out the old view and fade in the new view. The challenge is that the new content must be positioned absolutely until the old one fades out. I also want to set a specific top position and height for the new content, but when I try to ...

Deactivate the Submit button when the database field has been populated

My form includes a submit button. The Submit button should be disabled if the "price" for a specific product is already filled: PHP Code <?php $host="localhost"; $username="root"; $password=""; $db_name="ge"; $con=mysqli_connect("$h ...

Having trouble with implementing Nested routes in Vuejs?

main.js import Vue from "vue"; import App from "./App.vue"; import VueRouter from "vue-router"; import HelloWorld from "./components/HelloWorld"; import User from " ...

Point the direction to nextjs and react native expo web

I am currently working on redirecting a URL to another within my website, specifically in Next.js and Expo React Native Web. While I don't have an actual "About" page, I do have other pages nested under the "about" folder and am aiming to direct any ...

"Exploring the Magic of Jquery's Fadein() Animation

i have experience with writing code for a jQuery fadein effect. imagine I have an HTML element stored in a variable, like this: var sHtml="<div>Other content</<div><div id='frm'>hello</<div>"; modal.load(jQuery(sHt ...

What is the best way to dynamically adjust the color of table rows based on an input?

Currently diving into the world of javascript, jquery, and ajax. In need of guidance on how to tackle this particular problem: I have a table listing "expenses" that occur on a monthly basis: Type Cost Monthly/yearly Laundry 2000$ ...

Assign a complete object to the v-model of a Vuetify v-select

My vuetify select component looks like this: <v-select class="ml-4" v-model="selectedProjects" :items="projects" item-text="name" item-value="id" chips :menu-pro ...

What is the best way to choose all checkboxes in a specific column of a GridView?

In my GridView, I have two columns of checkboxes. I need to add separate "check all" buttons above each column - one for column A and one for column B. The "check all" button above column A should only check the checkboxes in that column, while the one abo ...

Tips for styling my date using MomentJS

I am currently using moment.js for displaying dates in my application. The date format is determined based on the locale stored in the variable clientLanguage. I have tried various approaches, including the following: moment(myISODate).locale(clientLang ...

Include certain tags to the content within the text apart from using bbcode tags

I need help with a project involving a BBCODE editor that can switch between a WYSIWYG editor and a code editor. The visual editor is designed with a drag-and-drop block system for elements like pictures and text. In the visual editor, when a user drags ...

Having trouble syncing a controller with AngularJS

Despite numerous attempts, I am still struggling to make a single controller function properly. Lately, I've been working on Angular projects and no matter what I do, my controllers just won't cooperate. In my latest project, everything is withi ...

Why isn't the AngularJS injected view resizing to fit the container?

As a novice delving into a project in the MEAN stack, I'm encountering inconsistent HTML previews. When I view it independently versus running it from the project, the display varies. Here's the intended appearance (in standalone preview): imgu ...

Carousel malfunctioning, refusing to slide smoothly

I recently copied the bootstrap 5 Carousel code and tweaked it with some additions, however, it's not functioning correctly. It seems to only go to the 2nd slide and then stops. Strangely enough, when I open the developer tools (F12) and go to inspect ...

Oops! Looks like we ran into a bit of a snag with the process_metrics

During our recent Protractor tests, we have been encountering warnings in the console: [12252:14584:1207/223118.187:ERROR:process_metrics.cc(105)] NOT IMPLEMENTED [12252:14584:1207/223118.187:ERROR:process_metrics.cc(105)] NOT IMPLEMENTED [12252:14584:120 ...