Clear Dashboard Text Input and Set Drop Down, Switch, Slider, Numeric and Date Picker to Default with Button

Hi,

I'm expecting a dashboard button to clear input text and set drop down, switch, slider, numeric and date picker to default on click.

I know there is Cancel button on form node by default, but I'm not using form node at this moment as I need drop down. The drop down element is not available on form node.

Thanks for helping.

So what have you tried so far? I'd try having an inject button send something to each of the ui nodes you want to reset and figure out how to reset each one (read the node info for each). once you get that to work, you could have your reset button link to the flow that resets the ui codes you are using.

Hi,

I added change node and set the msg.payload to string (null) after the button. Then I connected the change node to the dashboard inputs.

Did that work?
As @zenofmud suggested it might be simpler initially to connect inject nodes to each one then you can experiment with different values till you find out what you need to inject for each type of field.

Did you look at the info tab for each of the ui-nodes to see what is needed to reset them?

I tried the following:

[{"id":"8f1e9a5e.0b27d8","type":"ui_dropdown","z":"85a0b8d9.6add58","name":"","label":"","place":"Select option","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"options":[{"label":"Amy","value":1,"type":"num"},{"label":"Bob","value":2,"type":"num"}],"payload":"","topic":"","x":460,"y":60,"wires":[[]]},{"id":"fd1982c3.b54f1","type":"ui_switch","z":"85a0b8d9.6add58","name":"","label":"switch","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":450,"y":120,"wires":[[]]},{"id":"d3af1ed2.88646","type":"ui_slider","z":"85a0b8d9.6add58","name":"","label":"slider","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","min":0,"max":10,"step":1,"x":450,"y":180,"wires":[[]]},{"id":"f96b24d.6b9b9d8","type":"ui_numeric","z":"85a0b8d9.6add58","name":"","label":"numeric","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","format":"{{value}}","min":0,"max":10,"step":1,"x":460,"y":240,"wires":[[]]},{"id":"c9945030.42ae2","type":"ui_text_input","z":"85a0b8d9.6add58","name":"","label":"","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":300,"topic":"","x":460,"y":300,"wires":[[]]},{"id":"9759df3e.f4c2f","type":"ui_date_picker","z":"85a0b8d9.6add58","name":"","label":"date","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"topic":"","x":450,"y":360,"wires":[[]]},{"id":"212555b2.082b3a","type":"ui_colour_picker","z":"85a0b8d9.6add58","name":"","label":"","group":"b44d8a41.4ba8a8","format":"hex","outformat":"string","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"dynOutput":"false","order":0,"width":0,"height":0,"passthru":false,"topic":"","x":470,"y":420,"wires":[[]]},{"id":"60b44173.def3c","type":"change","z":"85a0b8d9.6add58","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":90,"y":240,"wires":[["11a3bb54.53c8a5"]]},{"id":"11a3bb54.53c8a5","type":"ui_button","z":"85a0b8d9.6add58","name":"clear-button","group":"b44d8a41.4ba8a8","order":0,"width":0,"height":0,"passthru":false,"label":"Clear","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":250,"y":240,"wires":[["8f1e9a5e.0b27d8","fd1982c3.b54f1","d3af1ed2.88646","f96b24d.6b9b9d8","c9945030.42ae2","9759df3e.f4c2f","212555b2.082b3a"]]},{"id":"b44d8a41.4ba8a8","type":"ui_group","z":"","name":"Group 1","tab":"491c9b78.645584","order":1,"disp":false,"width":"6","collapse":false},{"id":"491c9b78.645584","type":"ui_tab","z":"","name":"I4Inari - Clear Inputs","icon":"dashboard","order":4}]

It seems that text input, slider, numeric, date and color changed to default once I click the Clear button. But, the switch never change to off state back. How to make that the switch back to off once I click on the Clear button? The following is the information of the switch:

image

Can you use a ui_button to do that same thing, instead of a switch?

Yes, I can use a button. I think it's better idea.

ummm how about sending it an 'off'?

Inject msg.payload with boolean = false. It worked for me.

To set it on or off you have to send it exactly the value that it is configured to send. So since yours is set to send boolean true or false that is what you have to send it to set it on of off via a message.

1 Like

Hi Andrei,

Thank you very much. It worked for me as well. Appreciate your help.

1 Like

Do you understand why sending false worked?

Hi Colin,

The on and off payload on switch node had been set as true and false. When send false, it turns off the switch. This is what I understand. Maybe you have other reasons that I didn't notice.

I was just checking, since you did not respond to my post saying exactly that.

I see. I'm sorry, Colin. Thank you very much for helping.