feat: allow to pass parameters to dialogs #2470
Labels
community:request
Issues specifically reported by a member of the community.
status:needs-investigation
Needs additional investigation
vNext
For the next major version
🙋 Feature Request
I'm writing this feature request as a result of my discussion, which can be found here: #2443
The issue here is to collect and exchange feedback regarding the
DialogService
within this library. In my opinion, the current way dialogs work isn't very useful in many cases because their use case only fits in very specific ways.😯 Current Behavior
Currently, you can only bind to components that implement either
IDialogContentComponent
orIDialogContentComponent<T>
. In addition, you cannot pass additional parameters to the dynamic component. You either need to add them to your model or create custom parameters that inherit fromDialogParameters
and cast them within your component every time. Both ways result in much boilerplate code, which is hard to maintain.💁 Possible Solution
I would like to be able to use this kind of syntax:
The component itself should then create an instance of the provided component and fill all parameters. It would be even better if I could pass functions from the dialog itself as parameters.
🔦 Context
I want to pass additional parameters from outside to my dynamic component. For example, some sort of filters or rules for displaying content within the component itself.
In addition, I want to be able to use any component as a dynamic component for a dialog without having to implement the IDialogContentComponent or IDialogContentComponent interfaces every time.
💻 Examples
Let's say I have a component that displays a user list and allows me to filter them by name. So, I provide a filter class named
UserFilter
, which contains both age and username attributes.Now, I have certain views. The first view should always display users above the age of 18. The other one can be changed according to the user's needs. So, I don't want the user to change the value for the age filter in view 1.
In Blazor, I would achieve this like this:
View 1:
View 2:
The alternative would be to apply this property to my filter class, but I don't want to change my filter model. In some cases, I cannot change the class at all since I cannot modify the original source files.
The text was updated successfully, but these errors were encountered: