Utilizing Vuejs and ElementUi to enhance slot filtering capabilities

I am facing an issue with a table where one of the columns is using slot-scope, and I am struggling to include that column data into the filters option.

Code

Component filter input

<el-input v-model="filters[0].value" placeholder="Type to filter"></el-input>

component HTML

The problematic part is currently commented out

<data-tables class="bg-white shadow-sm"
    :data="transits"
    :filters="filters"
    style="width: 100%">
    <el-table-column prop="name" label="Name" sortable="custom"></el-table-column>
    <el-table-column label="Barcode" sortable="custom"> <!-- unable to integrate this data into filter -->
        <template slot-scope="scope">
            <div v-if="scope.row.barcode.serial_number">
                {{scope.row.barcode.serial_number}}
            </div>
            <template v-else>
                {{scope.row.barcode.u_serial_number}}
            </template>
        </template>
    </el-table-column>
</data-tables>

Component Script

I have provided more sample columns in the filters function for better understanding of the logic behind the element-ui table

<script>
export default {
    props: ['user'],
    name: "adminOuterTransits",
    data() {
        return {
            transits: [],
            filters: [
                {
                    value: '',
                    prop: ['formNo', // works (belongs to transit table)
                            'receiptNo', // works (belongs to transit table)
                            'description', // works (belongs to transit table)
                            'fob', // works (belongs to transit table)
                            'gudang', // works (belongs to transit table)
                            'ship_via', // works (belongs to transit table)
                            'sent_at', // works (belongs to transit table)
                            'received_at', // works (belongs to transit table)
                            'barcode'], // DOESN'T WORK (IT'S RELATIONSHIP DATA "barcode.serial_number")
                }
            ]
        }
    },
    // rest of it....
}
</script>

Does anyone know how to add the barcode data to the filter input?

Answer №1

Perhaps it would be more effective to mention the extension in element-ui next time ;)

To address your question about filtering on the barcode prop, you will need to create your own filterFn since there is no predefined prop on the el-table-column and the prop remains undefined

Make sure to refer to the diagram provided here


If you prefer not to use vue-data-tables, you can also utilize a computed dataset as demonstrated in the example on the element-ui page:

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

Tips on serializing two arrays into JSON format and incorporating them in an AJAX request

I have a task where I need to retrieve all the names and details associated with a specific reference number. To accomplish this, I am using a while loop. However, I am unsure of how to encode these values in JSON format so that I can use them in AJAX for ...

Discovering the correct element and typing for an HTML attribute through JavaScript

We are currently working on test automation and I am looking for a way to identify the Element and Type associated with it within an html (Data-qa) attribute. For example, when looping through, the Element is identified as input and the type is radio. < ...

Instructions for implementing this script in HTML and JavaScript: utilize the clone() function

I came across this code snippet here function displaytickets(){ var $panel = $('<div/>').addClass('col-xs-3 panel panel-default') $panel.append($('<div><h3 class="panel-title">Title</h3></div>&a ...

When scrolling back to the top of the page, the data-spy feature does not re-highlight the "Home" anchor

After experimenting with Data-spy to change the active anchor while scrolling, I encountered an issue. Upon scrolling back up to the top of the page from the about section, the "Home" anchor failed to re-activate. How can this be fixed? I attempted to rem ...

What is the method for retrieving the IDs of checkboxes that have been selected?

I attempted running the following code snippet: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://static.jstree.com/v.1. ...

Importing JavaScript files to work with Vue-Router: A Step-by-Step Guide

Seeking guidance on importing JavaScript files correctly throughout my Vue project, including within the components used to implement changes with Vue-Router. Currently, encountering an issue where I must reload the component in order for the JavaScript to ...

What is the reason behind vue-datepicker automatically adding 4 hours to the user-selected time input?

I'm currently facing an issue with integrating vue-datepicker within Laravel Breeze/Vue. For some reason, the datepicker seems to add 4 hours to the time selected by the user. This means that if a user picks 10:00 AM, the datepicker displays it as 14: ...

Encountering a deployment issue on Vercel while building with NextJS

I'm facing issues while attempting to deploy my Nextjs app on Vercel: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: (0 , react_development_.useState) is not a function or its ret ...

Examining the process through which an element attains focus

Scenario I am working on a Backbone application that has an event listener set up for focus events on a textarea. Since Backbone relies on jQuery events, my main concern revolves around jQuery focus events. Inquiry Is there a method to determine how an e ...

Navigating the Google Maps API: Implementing Scroll Zoom to Focus on a Single Marker

I'm looking for a solution for my project where the scroll zoom function will focus on zooming in on a marker or specific point rather than defaulting to the cursor. The current behavior is that the scroll zoom always centers on the cursor. Can anyone ...

What is the best way to send an image along with an array in a Vue Axios post request?

Here, I store the form data in an array along with an image. this.tableData.push({ sub_group: this.items.subGroup, amount: this.items.amount, item_name: this.items.item_name, quantity: this.items.quantity, category: this.items ...

Implementing secure Laravel storage with Videojs and Vue.js

I am encountering an issue with accessing privately stored videos from my server using laravel, videojs, and vuejs. Below is the code snippet of my controller method: public function fetchPrivateVideo($video) { $video_path = '/private/courses/e ...

Choose between creating an observable pipe within a function or storing it in a variable

Currently, I have a functional code snippet that leverages the Angular service to create an Observable pipeline. This pipeline utilizes operators like mergeMap, filter, map, and shareReplay(1) to manage user authentication and fetch the onboarding status f ...

Unexpected Issue Encountered in JQuery Integration

I recently added jQuery to my HTML file: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> After that, I included a link to my JavaScript file: <script src="public/javascripts/new_javascript.js" type ...

Node JS Promise does not provide a value as a return

Struggling with getting a value back from the code snippet below, even though it console logs out without any issues. Any suggestions on how to assign a value to X? var dbSize = dbo.collection('Items').count() var x = 0 x = dbS ...

Exploring the combined application of the AND and OR operators in JavaScript programming

{Object.keys(groupByMonthApplicants).map((obj,i) => <div key={obj} style={(i > 0 && (this.state.selectedTabId !== 'rejected' || this.state.selectedTabId !== 'approved')) ? {paddingTop:'15px',background:&a ...

Node.js application experiences a crash upon entering incorrect credentials

Would you mind reviewing my Login Function? After entering incorrect credentials, a response is sent but unfortunately the app crashes The versions I am using are Express ^4.17.2 and Node.js v16.14.0 router.post( "/login", [ body(" ...

Title remains consistent | Angular 4

Struggling to change the document title on a specific route. The route is initially set with a default title. { path: 'artikel/:id/:slug', component: ArticleComponent, data: {title: 'Article', routeType: RouteType.ARTICLE, des ...

What is the best way to ensure one div expands to full width while simultaneously hiding another div on the page?

Hey there, I'm looking for a way to expand the width of a clicked div while making the other div disappear from the screen simultaneously. It should also be toggleable, so clicking the button again will shrink the div and bring back the other one. For ...

Is it possible to delete browsing history in Express using node.js?

Upon user login, I store user information in browser sessions on the client side (using Angular) like this: $window.sessionStorage.setItem('loggedInUser', JSON.stringify(val)); For logout authentication on the backend (using Passportjs), I have ...