Multiple datasets in one PCF
This one I didn’t expect in the first place. But it was the comment that I’ve saw in the manifest, when I made my first dataset PCF:
That’s a wonderful possibility. I’m so happy that the PCF team designed it that way.
Defining the manifest for multiple datasets for the first dataset (it seems to me that the “cds-data-set-options” is designed mostly for the main dataset):
In the customizing, we start by defining the control for the view/subgrid that we choose, and after that, we get the chance the define views for the next data-sets:
I have a lot of use cases for that.
For instance, you make a PCF for writing recipes (no, it’s not a use case that I really needed , but why not…😉). You have a list with common ingredients (that you need in every recipe) and want to show them from the beginning in the list. This way the user only needs to introduce the quantity for that. So the PCF would be registered on entity “Recipe ingredients” for one recipe, and the second dataset would provide a view with “Common ingredients”.
Another use case would be: having a set of questions that somebody has to answer for each account. The first dataset would be registered to the “Answer” subgrid on the account form, but the questions should be already shown in your component (for both answered and not answered questions). Pretty handy that you can define the questions as a second dataset for your PCF, allowing the customizer to choose the view that it’s needed.
In my opinion, multiple datasets are a great feature offered by the framework ❤️.It’s elegant to allow the customizer to choose views, with the same customizing experience, instead of defining some fetchXLMs in a custom WebResource, having a different syntax in each config webresource.
😮 I could use multiple datasets in ModelDriven apps, but the import of the component failed in CanvasApps. I don’t know right now if it’s just a bug, or it will be a limitation. I hope it will be fixed soon.
How does multiple datasets integrate with the possibilities that we saw until now?
The paging, sorting, filtering, addColumn, refresh applies each to a dataset, so there is no confusion where they should be applied. They just work for every dataset.
The text introduced in the search box is used to filter all the datasets. For the text introduced in the search box, all the datasets will be refreshed based on the new searched text.
Autofilter on parent entity for subgrids
Used as a subgrid, the primary data-set is automatically filtered to the parent record (if you customized it that way). The other datasets are not filtered, even if they target the same entity as the primary dataset. But you can, of course, add more filter to each dataset, using the context.parameters.<myDataset2>.filtering.
Does <property-set> work if we define it in the other datasets too? Yes, it works! ❤️
First of all we can use the other datasets exactly the same as we work with the main one; same purpose.
I hope we can do even more with this feature. Actually, when we work with more datasets, usually we have some kind of connection between the datasets. Maybe we need to copy some more properties from one dataset to another, and then we need to know how to map this attributes. I haven’t tried it out yet, but I definitely will.
Combination of <data-set> and <property usage=”input”> in the same manifest
Yes, I could use both multiple datasets and property usage “input” in the same manifest. I think this combination is even more interesting than using it with only one dataset, because the host entity for a subgrid doesn’t have to be directly linked with the further data-sets. Maybe it’s only a “logical connection” between the form and the second dataset defined in the PCF. But we can use code, and based on the input parameter can inject special filters to the second or third dataset.