Skip to content
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

How to change display value when editing form? #767

Closed
sinall opened this issue May 28, 2020 · 8 comments
Closed

How to change display value when editing form? #767

sinall opened this issue May 28, 2020 · 8 comments

Comments

@sinall
Copy link

sinall commented May 28, 2020

I have a dropdown and a text input, when editing, I want to change the text of the input if dropdown is changed.

[some text] => I want to change view value of this input
[dropdown] => if a new option is selected

I tried to set editableForm['name of input']['$viewValue'] or set editableForm.$data['name of input'], but didn't work.

Here's the demo.

@ckosloski
Copy link
Contributor

Maybe this previous issue with help #521

@sinall
Copy link
Author

sinall commented May 29, 2020

@ckosloski The user case is different. In my case, I want to change the display value, regardless it is triggered by dropdown or a button. I don't want to save the display value to model until user click the save button.

The real case is like this:
[0 0/1 9 * * * or 2020-05-29 09:40:00] => I want to change view value of this input
[CRON or FIXED_TIME] => if a new option is selected
I use single input field to save the expression which could be a CRON expression or a DATA TIME expression. So it will have very different formats according to its type.

For example:
[2020-05-29 09:40:00] => change display value to empty
[FIXED_TIME] => if option is changed to CRON
In this case, I want only the view value get changed, if will be saved to model if save is clicked or will be discard if cancel is clicked.

I guess I could use jQuery to change the input value, but I don't what will happen, and I don't know if angular-xeditable have such API to achieve this.

@ckosloski
Copy link
Contributor

Try this demo
Change the group drop down and the user name changes.

@sinall
Copy link
Author

sinall commented May 30, 2020

@ckosloski Demo
It can‘t be saved into model when save is clicked. So the view-model binding is broken. Somehow this method is different from user manually change.

@ckosloski
Copy link
Contributor

Are you referring to the error message Username should be `awesome` or `error?
That was in the original demo link you posted.

@sinall
Copy link
Author

sinall commented May 31, 2020

Are you referring to the error message Username should be `awesome` or `error?
That was in the original demo link you posted.

No, I changed the link several times, it should be this demo.

@ckosloski
Copy link
Contributor

This seems to work

@sinall
Copy link
Author

sinall commented Jun 4, 2020

@ckosloski Thanks you, it works!

@sinall sinall closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants