EasyUI Forum
May 17, 2024, 05:45:24 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Set Default values on Clear() [solved]  (Read 30991 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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
« Last Edit: May 20, 2013, 11:23:03 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 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 !
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: November 02, 2012, 02:01:43 AM »

Try refreshing the page and download it again.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #4 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
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 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.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #6 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 Huh

Thanks
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 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.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #8 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

Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #9 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/
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #10 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/

« Last Edit: May 20, 2013, 06:07:20 PM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #11 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)});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!