View Full Version : [FIXED-384][3.0.3] DirectStore does not create Reader

14 Dec 2009, 10:57 AM
Ext version tested:

Ext 3.0.3

Adapter used:


css used:

only default ext-all.css

Browser versions tested against:

FF3 (firebug 1.4.5 installed)

Operating System:

WinXP Pro


The Ext.data.DirectStore's constructor will not create the JsonReader if the 'fields' config is an Ext.data.Record constructor (instead of an array of fields). The problem lies right in the conditional operator in the call to the DirectStore's superclass constructor:

reader: (typeof(c.reader) == 'undefined' && typeof(c.fields) == 'object') ? new Ext.data.JsonReader( ... The reader will not be created if c.fields is an Ext.data.Record constructor because in that case:
typeof( c.fields ) == 'function'

Test Case:

var myRecord = Ext.data.Record.create( [ 'field1', 'field2' ] );

var myStore = new Ext.data.DirectStore( {
fields: myRecord,
directFn: Ext.ss.MyClass.myMethod,
autoLoad: true
} );
Error: 'this.reader is undefined' (Edit: Was just doing a bit more testing, and the thrown error itself might have been coming from a ComboBox, but the reader still does not get defined and the store does not load data.)

Possible fix:


reader: (typeof(c.reader) == 'undefined' && ( typeof(c.fields) == 'object' || typeof(c.fields) == 'function' ) ) ? new Ext.data.JsonReader( ... Or just:

reader: (typeof(c.reader) == 'undefined' && c.fields ) ? new Ext.data.JsonReader( ...

14 Dec 2009, 9:27 PM
I think the latter fix is probably the better option.

14 Dec 2009, 9:35 PM
Fix applied to svn in rev #5779 for patch release 3.1.1.

14 Dec 2009, 11:00 PM
Sounds good to me! I just put the first suggestion in there in case there was a reason for testing if c.fields was an object instead of just testing for its existence. Didn't seem like it, but ya never know B)

Thanks for the fixing.