How do display the fields of 2 collections (table) in one table view

Hi team!

I have 2 tables: Properties and location. Each property belongs to a location hence we have location_id as our foreign key in the property table.

As you can see in the screenshots below, the property table view has a location ID. Instead of the ID, I
would like to display the fields present in the location table to make it easier for my agents to filter out properties in a certain city, area, or region

Property table:

Location table:

Required: on property table, I want to see the columns country code , city , area , and region.

Kindly advise how I can achieve this?

TIA

Hello @Yusra_Bagosher,

Sure you can do this using Smart Fields here’s a link to the documentation.

You need to add the country code, city, area and region Smart Fields to the forest/properties.js (or forest/property.js) file.

In your case those fields are related fields so you need to use the reference option. Here is a link on how to create Smart Fields with Smart Relationship (field with relation to other table). This example should illustrate exactly what you need.

I hope it will respond to your request (if I got it right). :slight_smile:

Kind regards,
Morgan

2 Likes

Hi, @Yusra_Bagosher

There’s also a database view approach, that might be helpful in your situation.

1 Like

@morganperre can we filter collection listing by SmartFields?

I added smart fields as described by @Yusra_Bagosher but they are not appearing in filters

Hello @Tauseef_Ahmed,

Yes, it’s possible but you need to code your own logic, because this mechanism overrides the default behaviour (you declare a specific get et search functions). I invite you to read the documentation on this subject.

Here is the documentation related to filters on smart fields.
And this one is a complete example of search on smart fields.

Kind regards,
Morgan

1 Like