EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on November 01, 2012, 08:06:23 PM



Title: Set Default values on Clear() [solved]
Post by: devnull on November 01, 2012, 08:06:23 PM
Because the default for a combobox, numberspinner etc is set as the input "value" attribute, when you clear the form form('clear') the value also gets cleared and so the field is then null.

Can this behavior be changed so that when a form is cleared, the combo box, number spinner etc default to their default values and not null ? - or add anew method reset() which sets all controls on the form to their default state / values ??

Thanks


Title: Re: Set Default values on Clear()
Post by: stworthy on November 02, 2012, 01:53:00 AM
The attached file is the simplest extension of reset method. It will be improved and integrate into next version.


Title: Re: Set Default values on Clear()
Post by: devnull on November 02, 2012, 01:55:37 AM
Thanks, but when I click on the file attachment I get:

"You are not allowed to access this section" even though I am logged in !


Title: Re: Set Default values on Clear()
Post by: stworthy on November 02, 2012, 02:01:43 AM
Try refreshing the page and download it again.


Title: Re: Set Default values on Clear()
Post by: devnull on March 14, 2013, 05:02:26 AM
The function included into the latest release is acting like clear() and not reset()

http://jsfiddle.net/uAqKG/2/

When the form is reset, the default values for combobox, numberspinner etc etc should be reset to their default, instead, they are being cleared.

Thanks


Title: Re: Set Default values on Clear()
Post by: stworthy on March 14, 2013, 07:43:41 AM
In the http://jsfiddle.net/uAqKG/2/ case, the combobox has no initialized value since its value property is not set. Please refer to the updated sample http://jsfiddle.net/uAqKG/3/. It works fine.


Title: Re: Set Default values on Clear()
Post by: devnull on March 14, 2013, 04:20:44 PM
Thanks

But that is not really very practical, as it means for a combobox, you need to set BOTH the value and the selected option to be identical.

Instead of using the value field, why not get and use the Selected Option from the element's field array instead ???

Thanks


Title: Re: Set Default values on Clear()
Post by: stworthy on March 14, 2013, 05:53:04 PM
The selected option item is not the original value. Otherwise the original value may be changed when users load a new data set.


Title: Re: Set Default values on Clear()
Post by: devnull on May 20, 2013, 05:28:34 AM
Hi again:

http://jsfiddle.net/uAqKG/5/

Is it possible to apply the reset method to the datebox as well as combobox so that during a form reset, it's value does not get cleared.

Thanks



Title: Re: Set Default values on Clear()
Post by: stworthy on May 20, 2013, 06:31:18 AM
Please download the updated form plugin from http://www.jeasyui.com/easyui/plugins/jquery.form.js. The example is available here http://jsfiddle.net/uAqKG/6/


Title: Re: Set Default values on Clear()
Post by: devnull on May 20, 2013, 06:02:46 PM
Thanks so much, but unfortunately this does not work when the value is set programatically: http://jsfiddle.net/uAqKG/8/



Title: Re: Set Default values on Clear()
Post by: stworthy on May 20, 2013, 06:27:43 PM
Please refer to http://jsfiddle.net/uAqKG/10/.
The original value is stored when datebox is created first. Calling 'setValue' method can only change its current value. So you need to create datebox with 'value' set to the original value.
Code:
$('#date1').datebox({value:$.fn.datebox.defaults.formatter(g_now)});