Skip to content
Advertisement

Display lookup/relational data in a v-data-table with Vue and SQLServer

I created a Node App with Vue.js, Vuetify (Client side of app) and Express (Server side of App) and the data is stored in a SQL Server database (relational database).

Everything is up and running on my development machine and connection between client, server and database is working.

I just don’t know how to display “Lookup Data/relational data” in the tables that I am using.

3 tables of my database:

Relational tables

So I would like to display the Name fields of AssetMake and AssetModel INSTEAD of the FKAssetMake and FKAssetModel.

This is a screenshot of my table in the browser:

Table display

As you can see, the FK values are displayed but not the names.

The lookup tables and data to be displayed:

Lookup table data

Data object in chrome:

enter image description here

My Vue template:

Script part:

  1. How do I display the Name field of the referenced table instead of the Foreign Key.

  2. Is there a “better” way to accomplish the task with a “web type” database design?

Advertisement

Answer

@chans’s answer got me on the right track.

As the users will not be editing the data in the table ‘in-line”, one can change the query to show the data needed (AssetMake.Name and AsseteModel.Name).

I am using a dialog with a form to do the editing and adding of Assets. I then use a v-select to display the lookup data like this:

assetModels contains all asset models and was fetched from the database on mounted event.

Thanks to all who participated.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement