161
Views
6
Comments
Solved
[OutSystems Data Grid] Format Column Value By Getting Data From Other Entity
outsystems-data-grid
Reactive icon
Forge asset by OutSystems

Hi, context: I have two entites User and Order. The Order entity has User Identifier as a foreign key.

I am now displaying the Order entity in a grid table, and for the User column, it is binded to the UserId attribute, so it's showing the UserId by default. But I want the column to display the name of the user instead. How can I achieve that?

Hopefully the team can implement an easier way to format the binding value in the future.

2023-01-26 16-03-24
Ana Agostinho
Solution

Hello Max Chia, 


In order to display the UserName and not the UserId, you need, on the aggregate or data action that you are using to retrieve the data for the grid, by joining the entities Order and User on Order.UserId=User.Id, and you can retrieve only the data you desire, by grouping the info in the columns, for example. You might need to create a structure with the attributes that you want to show on the data grid and set it as the output of your aggregate/data action. 

Best regards, 

Ana

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Max Chia ,

there is not much any 'team' can do about that for you.  

The grid doesn't know your datamodel, it just gets a JSON with fields to show.  

If you want something to show in the grid, you have to retrieve that in your aggregate , so you should add user as a source, then the user name becomes available for you to show in the grid.

Dorine

UserImage.jpg
Max Chia

Hi @Dorine Boudry ,

To add more details on what I hope the data grid team could consider implementing, is to allow the usage of functions in column's Binding to format the column's value directly, instead of creating another structure to hold the formatted values. I think this would be more convenient to the developers. Thank you.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Ah ok,

i completely did not get that from your original post.  I think what you are asking is A LOT, and really not in sync with things like separation of concerns.  

The grid is only a front end (i.e. javascript running on the user's device) tool for presenting data in the browsers UI, an aggregate is back end (i.e. running C# and SQL) on server side for retrieving the data you want to show.  

The data resides in a database on the back end.  The aggregate or sql has a richness of language to get out of the database what you need. 

You are now asking that this front end javascript solution would concern itself with data retrieval and all that encompasses.  You would then need to incorporate in that datagrid functionality, all the language constructs you already have in aggregates / sql to express how the extra piece of information you want relates to what you already have (joins, filter,...)

I'm also not really getting what you say with "creating another structure", if you join another entity into your aggregate, it's attributes become available in the output without doing anything extra.

Dorine

2023-10-26 15-12-53
Mohammed Rizwan

Hello Max

You have to get the data from database using aggregate and add both the sources order and user 

table then bind with the grid it will work

Demo: https://personal-abfdzfhg.outsystemscloud.com/Sample/Orders?_ts=638176034591808890

I have create  working sample for Your refrence find attached oml

Thanks

Mohd Rizwan

Sample.oml
UserImage.jpg
Mikasara Tanaka

Hi, is that possible to allow user to edit date grid with aggregate which has multiple entity? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.