How to load additional data into a datalist inside a column template of a datagrid

I try to invoke an additional data source for every row in a datagrid. I have a datagrid based on a DB table attachments and a DB view that relates tags to attachment IDs.
This is how far I got:a datalist of badges is showing in the column, but the list does not depend on the attachment id of each row: only the first file has a tag in the DB view.

This is the AttachmentTagView from the DB, that I try to lookup the tag name for every attachment ID:
image

This is the datagrid column configuration in the created .json file:

How can I get all tags belonging to an attachment showing up in one cell?
Thanks a lot for any advice.

Hi @rene,

Usually related data are exposed as sub properties that can be expanded. For example Customer-> Orders from Northwind database:

If there is no relationship you can perform a database call to get additional data using row data item.

A) To do this you can use pure no-code style approach with a CustomComponent to perform the database call on load:

  1. Create a page with no navigation that will server as component, perform database call on Load with the following filter and set the result to a property bound to heading Text:




  2. Add additional column to the DataGrid, define CustomComponent in the column Template and use the page from previous step as source. CustomerID is set as attribute:


  3. Run the application:

B) You can perform database call using a custom method defined in the page partial class:

  1. Define custom method:

  2. Execute the method when needed - in my case in column template:

  3. Run the application:

You can get the application illustrating all three approaches from here:
https://drive.google.com/file/d/19tlxXZbMbjck55AVMsMaOcxTS9nucXwz/view?usp=sharing

  • I'm my example I'm returning Count() of the detail records however you can extend it to return data and bind desired component to that data.
1 Like

Thanks a lot @enchev for this detailed explanation. I tested approach A) and it works very well: the last column is using the CustomComponent.


I will also try out B) because sooner or later this will come in handy.