Show data from two tables in a datagrid

hello!

I have a question… can I bring data from two tables to a datagrid?

ex: a table contains name and function

another table contains the email.

I need to show these 3 data in the datagrid. Can I do this just from the frontend? without having to manipulate the database (supabase).

Yes, but you have to join them first on the front-end, can you show us the table details?

These are the two tables, I need to show the ‘position’ and ‘name’ information from the employees table in the datagrid
image

In the user_work_profiles table, I need to show the ‘email’ information.
image

I need to take these three pieces of information to this datagrid

@luka ?

Sorry, didnt see the noti

Is there a reason why you dont use an addon function in xano to have them both in one collection?

If you want to do it on the frontend, you would have to use custom javascript in a forrmula and it would look like this

return YourFirstCollection.data.map(item1 => {
    const matchingItem = YourSecondCollection.find(item2 => item1.id === item2.id);
    return {
        id: item1.id,
        name: item1.name,
        position: item1.position,
        email: matchingItem ? matchingItem.email : null
    };
});

no problem…

I’m using supabase in this case

@luka, as you are part of the team, would it be possible to make a video using Supabase?

If you want to update a row in Supbase, you’re probably going to want to use the Supabase Update action in a workflow, select the id of the item you’re updating and then it’s pretty similar to the video above

Let me know how it goes and i can help you additionally

example: I have a quotation system for companies only. After registering the company in the system, this same company can register its employees to use the functions related to quotations and budgets… my question is, when you refer to the item ID, in my case, it would be the company ID or the employee ID?

Well that depends on what table you want to update, from my understanding you are going to want to update the employee with the employee id

@luka, this employee to be edited, has related data in 2 tables!

“user_work_profile” = ‘email’ field
image

“employees” = field ‘name’,‘position’.
image

But before that, I need to bring this data above to the datagrid, in this case I need to bring data from 2 tables to the datagrid and thus be able to edit this data and also delete it if necessary.

see if I’m on the right path: I created a collection for each table.
image

Now in my datagrid, I need to bring this information and show these three pieces of information in the grid

You instructed me to use custom javascript to relate this data in the table, but how will I bring this information from supabase?

Sorry for all the inconvenience, but I’m stuck on this… kkk

You can click on your Supabase collection data in the formula even when its in Javascript mode

But you should really look into Supabase SQL editor and learn more about joining two tables in supabase instead of weweb

1 Like

I believe that at this moment the best thing would be to do it through the backend, but I thank you for your attention so far!

Thank you very much