-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset value of element to original json value #71
Comments
Hi,
In that case your Hope that helps Edit: I know it is not a very systematic solution, because this component would always reset its value when it is hidden which makes it difficult to reuse. |
Hi, I've implemented your suggestion of using the isVisibleChanged stream to reset my custom component's value. But I'm currently having a problem with the stream itself, the two states that I'm receiving in the async snapshot from the StreamBuilder are true and null, I never get a false indicating that the form element that I'm trying to reset is not visible. Even when I'm using the isVisible property, It returns true or null. If I print the output from the properyChanged stream I also have the same outcome, never "isVisible", only null or "value". My problem at the moment is that I want to reset the value when the form element is hidden, but It's resetting when it becomes visible a second time, if I use the .getFormData() the hidden component's value is still being outputted. Thanks for the previous reply, and sorry to bother you a second time. |
Hi, sorry for the late response. Firstly, Are you sure you have correctly set your Do you think you can provide some minimal reproducible example so I can try it myself? Or at least relevant part of the code (render, XML/JSON...). |
Hi, I'm sending the files of the custom components that I've implemented, I'm also sending the json file that I'm using to debug. The behavior happens in every component that I've modified. Again, sorry to bother you, I imagine that the pandemic must be putting a strain on all of us, so I appreciate you taking some of your time to help me with this :) |
Hi, Thanks for the code! I already see the problem and it is quite an interesting and challenging one. That's the general problem of the renderer classes - they may be added and removed from the widget tree but we need to have this logic in a persistent place. That's when I realized it should not be part of the renderer but rather part of the model class, because there is a single instance of the model that never changes. What we need to do is to subscribe to the isVisible changes and change the value property. Unfortunately, we cannot subscribe to the Stream in a model constructor, because the Stream is not prepared yet. We would need some lifetime callback on a model which will be called when the Stream is ready - this is something that should be implemented in the future version. However, there is a workaround - just put this inside your
And in your renderer just make sure this method is called (this will not be necessary when we have lifecycle callback on the model):
I hope this helps. It is not bothering at all. This is exactly the type of issue that can improve the library! Btw. in my case lack of time is not so much about the pandemic but rather about a newborn child :) |
Hi, I'm currently trying to reset the value of a radioButtonGroup from a checkBox, but when I use the expression syntax to set its value, the radioButtonGroup becomes immutable and responds only to the changes in the checkBox.
I'm no sure if I overlooked something in the documentation, or if its something else. My goal is to make the radioButtonGroup, invisible and reset its value to "-1" when the checkBox is unchecked.
Thanks for your time.
The text was updated successfully, but these errors were encountered: