Ext


Go Back   Ext JS Forums > Ext JS Community Forums (2.0) > Ext 2.x: Bugs

Reply
 
Thread Tools
  #1  
Old 08-06-2008, 06:30 AM
mildo mildo is offline
Ext User
 
Join Date: Jul 2008
Posts: 3
mildo is on a distinguished road
Default [2.2][FIXED] Exception in Checkbox.setValue on non-rendered checkbox

After update to 2.2 a call to setValue on a checkbox with rendered == false causes exception "this.wrap is undefined".
Reply With Quote
  #2  
Old 08-06-2008, 06:33 AM
ovan's Avatar
ovan ovan is offline
Ext User
 
Join Date: Oct 2007
Posts: 32
ovan is on a distinguished road
Default

There is a workaround here.
__________________
ExtJS license owner
Reply With Quote
  #3  
Old 08-06-2008, 06:37 AM
Condor's Avatar
Condor Condor is offline
Ext JS - Community Support Team
 
Join Date: Mar 2007
Location: The Netherlands
Posts: 14,249
Condor is on a distinguished road
Default

Yes, setValue() seems flawed. I also have my doubts about getValue() always returning false for unrendered checkboxes.

I propose the following changes:

Ext.override(Ext.form.Checkbox, {
	getValue : function(){
		if(this.rendered){
			return this.el.dom.checked;
		}
		return this.checked;
	},

	setValue : function(v) {
		var checked = this.checked;
		this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');

		if(this.rendered){
			this.el.dom.checked = this.checked;
			this.el.dom.defaultChecked = this.checked;
			this.wrap[this.checked? 'addClass' : 'removeClass'](this.checkedCls);
		}

		if(checked != this.checked){
			this.fireEvent("check", this, this.checked);
			if(this.handler){
				this.handler.call(this.scope || this, this, this.checked);
			}
		}
	}
});
Reply With Quote
  #4  
Old 08-06-2008, 06:49 AM
mildo mildo is offline
Ext User
 
Join Date: Jul 2008
Posts: 3
mildo is on a distinguished road
Default

Condor,ovan
Thanks for your help!
Reply With Quote
  #5  
Old 08-06-2008, 01:01 PM
Guteman Guteman is offline
Ext User
 
Join Date: Oct 2007
Posts: 37
Guteman is on a distinguished road
Default

The work-around posted above works. I had an Ext.Window calling the loadRecord method on the "afterlayout" event which caused the this.wrap is undefined issue, the override works, phew!
Reply With Quote
  #6  
Old 08-06-2008, 02:46 PM
brian.moeskau's Avatar
brian.moeskau brian.moeskau is offline
Ext JS Contributor
 
Join Date: Mar 2007
Location: Austin, Texas
Posts: 3,258
brian.moeskau is on a distinguished road
Default

Fixed in SVN.
__________________
Brian Moeskau
FAQ / Tutorials / User Extensions / Enhanced Forum Search
Reply With Quote
  #7  
Old 08-26-2008, 12:45 PM
vijaypr.chak vijaypr.chak is offline
Ext User
 
Join Date: Aug 2008
Posts: 8
vijaypr.chak is on a distinguished road
Default

Mate -
Thanks for the reply.
I made the necessary changes in ext-all-debug.js, suppose i am changing in the right place, but still struck with same issue.
Is the latest fix available in SVN? or when it is expected.

Cheers.
Reply With Quote
  #8  
Old 12-27-2008, 07:51 PM
cyberwizzard cyberwizzard is offline
Ext User
 
Join Date: Jun 2007
Posts: 32
cyberwizzard is on a distinguished road
Default

I know this is an old topic but I would like to add that this results under Adobe AIR in a rather helpful error (this back trace comes from Aptana Studio):
TypeError: Undefined value
 at app:/lib/ext/ext-all-debug.js : 28140
selectRemoteInstance at app:/spice_loader.js : 89
 at app:/spice_loader.js : 184
 at app:/lib/ext/ext-all-debug.js : 1488
 at app:/lib/ext/ext-all-debug.js : 1184
 at app:/lib/ext/ext-all-debug.js : 12436
 at app:/lib/ext/ext-all-debug.js : 14062
 at app:/lib/ext/ext-all-debug.js : 14352
 at app:/lib/ext/ext-all-debug.js : 14341
 at app:/lib/ext/ext-all-debug.js : 14471
 at app:/lib/ext/ext-all-debug.js : 14331
 at app:/lib/ext/ext-all-debug.js : 14431
 at app:/lib/ext/ext-all-debug.js : 14327
 at app:/lib/ext/ext-all-debug.js : 14206
 at app:/spice_loader.js : 46
 at app:/lib/ext/ext-all-debug.js : 14073
 at app:/lib/ext/ext-all-debug.js : 14670
 at app:/lib/ext/ext-all-debug.js : 14327
 at app:/lib/ext/ext-all-debug.js : 14206
 at app:/lib/ext/ext-all-debug.js : 14079
 at app:/lib/ext/ext-all-debug.js : 12375
 at app:/lib/ext/adapter/ext/ext-base.js : 9
 at app:/lib/ext/adapter/ext/ext-base.js : 9
 at app:/lib/ext/adapter/ext/ext-base.js : 9
bootstrap at app:/spice_loader.js : 565
 at app:/lib/ext/ext-all-debug.js : 1488
 at app:/lib/ext/ext-all-debug.js : 1593
 at app:/lib/ext/adapter/ext/ext-base.js : 10
undefined at undefined : undefined
Particularly the last line is helping me a lot

The solution to this is to either implement the workaround or check if the component is rendered or not: if it ain't, set the value directly in 'component.checked'.

I hope this will save other AIR developers the 30 minutes or more it took me to figure this out on my own ^^
Reply With Quote
Reply

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 07:44 PM.

© 2006-2009 Ext, LLC
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.