Tips on adding additional values to a table column in Vue3 using Element-Plus

My database contains an array of objects with a 'sex' property that is either 1 for male or 2 for female. How can I use the el-table library to convert these values to display as 'male' and 'female'?

I am unfamiliar with this library and attempted various approaches, such as using v-if within el-table-column, but have been unsuccessful so far.

Answer №1

I finally came across a solution to my query. I discovered that I needed to include a default scope template in the header column without using props, allowing me to customize it with my own value.

<el-table-column prop="patron" label="Patron"></el-table-column>
<el-table-column  label="Sex">
  <template #default="scope">
    <span v-if="scope.row.sex === 1">Male</span>
    <span v-else-if="scope.row.sex === 2">Female</span>
  </template>
</el-table-column>
<el-table-column prop="dept" label="Dept"></el-table-column>

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

Convert HTML form input into a JSON file for safekeeping

<div class="email"> <section class="subscribe"> <div class="subscribe-pitch"> </div> <form action="#" method="post" class="subscribe-form" id="emails_form"> <input type="email" class="subscribe-input" placeholder="Enter ema ...

What's causing jQuery to make the entire page malfunction?

I am experiencing an issue where a function is not recognized as being in scope when I have a reference to jQuery defined. Oddly enough, if I comment out that reference, the function call works just fine. I have other pages set up the same way with jQuer ...

At which location within the script should I insert the document.title in order to update the title every xx milliseconds?

I have been working on a script that refreshes certain #id's. Additionally, I would like to update the page title, which involves some flask/jinja2. I've attempted placing document.title = {% block title %} ({{online_num}}) Online Players {% en ...

The BottomNavigation component in MUI has a minimum size limit of 400px when it displays 5 items

My issue involves a bottom navigation bar with 5 elements. When the window is resized to less than 400px, the bottom navigation does not shrink, instead maintaining a minimum width of 400px and causing a scrollbar to appear on the x-axis. You can view a m ...

Developing Modules in NodeJS using Constructors or Object Literals

I am currently developing a nodejs application that needs to communicate with various network resources, such as cache services and databases. To achieve this functionality, I have created a module imported through the require statement, which allows the a ...

Using Node JS to query data from MySQL and filter a column based on an array of objects

I am dealing with a column in my database that can either be null, contain a single integer, or multiple integers separated by commas. I need to filter specific rows based on this column. However, instead of using a search string, I have an array that coul ...

Retrieving sender information using jQuery within a Bootstrap iframe modal

I'm trying to integrate a Google Map into a Bootstrap 4.0 Beta modal window. After coming across this helpful post and implementing the code successfully, I realized I lack the necessary expertise in jQuery to achieve the specific functionality I des ...

What is the best way to save a hash in a form input field?

If I have a hash and want to pass it as a value with val() $("#form_attribute").val( hash ) Instead of storing it as a string "[Object, object]", how can I keep it as a hash and allow the form to send this hash to my server? ...

Looking to incorporate AAD calling functionality in a React and Node application by utilizing the Graph API for communication/calls

As a newcomer to Microsoft Azure and its services, I recently registered an application with Azure. However, when attempting to integrate a call feature in my Web App using the graph API '/communication/calls', I encountered the following error m ...

Get a calendar that displays only the month and year

I am looking to incorporate two unique PrimeFaces calendars on a single page. The first calendar will display the date, while the second one will only show the month and year. To achieve this, I have implemented the following JavaScript and CSS specifica ...

Generate a .py file through an HTML button click and save it to your device

My current project involves developing HTML and JavaScript code for a chatbot. I need to implement a feature where, upon receiving a Python program from the chatbot, a download button should be displayed. When users click on this Download button, they shou ...

Does the content only refreshes after the second click, never the first one?

Trying to figure out how to update text in a Bootstrap 3 Popover using JavaScript. I suspect my use of Promises is incorrect because the text only appears in the popover after clicking it twice. The JavaScript code involves calling a local C# Proxy. Here& ...

Using jQuery and CSS to Filter and Sort Content

I need help with filtering a list of content based on their class names. The goal is to show specific items when a user clicks on one of two menus. Some items have multiple classes and users should be able to filter by both menus simultaneously. Currently ...

Instructions on activating the standard scrolling function for a specific DIV element

I'm struggling to achieve a specific scrolling effect on my one-page website. I want the initial section to be displayed as a full page, and when the user scrolls down, it should transition to the next section with a full page scroll. However, once th ...

What is the best way to extract values from a string that are already mapped

Recently, I encountered this string: const string = "DEVICE_SIZE IN ('036','048','060','070') AND DEVICE_VOLTAGE IN ('1','3') AND NOT DEVICE_DISCHARGE_AIR IN ('S') AND NOT DEVIC ...

Connecting AngularFirebaseAuth: Running server API immediately following Firebase authentication?

My authentication process relies on two key factors: Using Firebase auth (email and password) Making a server API call to retrieve the complete customer entity from the database based on the firebaseID. The user must exist in both places for successful a ...

Resolve CORS error when uploading images with AJAX and Node.js using FormData

I am incorporating vanilla javascript (AJAX) to submit a form and utilizing Formdata(). The submission of the form is intercepted by nodejs and linked to a database. However, there is an issue that arises when I try to connect with nodejs after adding a f ...

When a number is added to an array containing strings, the result is a string rather than a number

Currently, I am attempting to change my array key value from a string to a number within my JSON object: form["price"] == "23" console.log(typeof form["price"]) // string form["price"] == Number(parseFloat(this.formObject[field.fieldName])) The issue aris ...

Error in Typescript for the prop types of a stateless React component

When reviewing my project, I came across the following lines of code that are causing a Typescript error: export const MaskedField = asField(({ fieldState, fieldApi, ...props }) => { const {value} = fieldState; const {setValue, set ...

There seems to be an issue with the conversion of GLTF

Exploring the world of threejs in react has been quite an adventure for me. I discovered that the key to displaying 3D objects in react is by converting them into a JSX Component using gltfjsx. Following the procedure, I tried working with both glb and glt ...