-
7 Dec 2011 6:28 PM #1
Issue with grouping a List
Issue with grouping a List
I have a list :
And store:Code:Ext.define('Test.view.PatientList', { extend: 'Ext.dataview.List', xtype: 'patientList', id: 'patientList', fullscreen: true, config: { itemTpl: '<div id="{id}">{lastName}, {firstName}</div>', store: 'PatientStore', grouped: true, indexBar: true } });
If I don't include the grouped and indexBar attributes, the list loads normally, showing all the data. However when I add these properties I get an error:Code:Ext.define('Test.store.PatientStore', { extend: 'Ext.data.Store', model: 'Test.model.PatientModel', requires: [ 'Test.model.PatientModel' ], sorters: [ 'lastName', 'firstName' ], getGroupString: function(record){ return record.get('lastName')[0]; }, autoLoad: false, autoSync: true, proxy: { type: 'ajax', api: { read: '../Services/PatientWebService.asmx/GetAllPatients' }, reader: { type: 'xml', record: 'PatientData', root: 'ArrayOfPatientData' }, afterRequest: function(response, opts){ } } });
Uncaught TypeError: Cannot call method 'insertFirst' of null
Because the me.getViewItems() inside sencha comes back as null.
-
9 Dec 2011 5:46 AM #2
-
9 Dec 2011 5:53 AM #3
Are you using the Sencha Touch 2 PR2?
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 5:56 AM #4
-
9 Dec 2011 11:16 AM #5
Can you provide a simple testcase please, including fake data?
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
9 Dec 2011 7:04 PM #6
I have a simmilar problem,
grouped list with only one item throws an error..
There is something like ...fly(items[items-length-2]) in Sencha Touch code...
-
12 Dec 2011 6:47 AM #7
The only way I can reproduce this is by using Ajax Proxy in my store, so this isn't as simple of an example as I'm sure you'd have liked. Here is my app.js
and here is my TestStore.jsCode:Ext.Loader.setConfig( {enabled: true} ); Ext.define('TestController', { extend: 'Ext.app.Controller', config: { profile: Ext.os.deviceType.toLowerCase() }, views: [ 'ContactList' ], init: function() { } }); Ext.define('Contact', { extend: 'Ext.data.Model', fields: ['firstName', 'lastName'] }); Ext.define('ContactList', { extend: 'Ext.dataview.List', xtype: 'contactlist', id: 'contactList', fullscreen: true, config: { itemTpl: '<div>{lastName}, {firstName}</div>', store: 'TestStore', grouped: true, indexBar: true } }); Ext.application({ name: 'test', models: [ 'Contact' ], stores: [ 'TestStore' ], launch: function() { Ext.create('Ext.Panel', { fullscreen: true, layout: 'fit', items: [{ layout: 'fit', xtype: 'contactlist' }] }); Ext.data.StoreManager.lookup('TestStore').load(); } });
and here is an example of the XML data I'm getting back from my WebServiceCode:Ext.define('test.store.TestStore', { extend: 'Ext.data.Store', model: 'Contact', sorters: 'lastName', getGroupString: function(record) { return record.get('lastName')[0]; }, autoLoad: false, autoSync: true, proxy: { type: 'ajax', api: { read: '../Services/PatientWebService.asmx/GetAllPatients' }, reader: { type: 'xml', record: 'PatientData', root: 'ArrayOfPatientData' }, afterRequest: function(response, opts){ } } });
You are probably going to have to make a webservice that mimics this data in order to recreate the issue.Code:<?xml version="1.0" encoding="utf-8"?> <ArrayOfPatientData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"> <PatientData> <id>252</id> <firstName>First5</firstName> <lastName>Last5</lastName> </PatientData> <PatientData> <id>253</id> <firstName>First4</firstName> <lastName>Last4</lastName> </PatientData> <PatientData> <id>254</id> <firstName>First3</firstName> <lastName>Last3</lastName> </PatientData> <PatientData> <id>255</id> <firstName>First2</firstName> <lastName>Last2</lastName> </PatientData> <PatientData> <id>256</id> <firstName>First1</firstName> <lastName>Last1</lastName> </PatientData> </ArrayOfPatientData>
This is the function that fails for me in sencha core because item is undefined:
and this is the call stackCode:doAddHeader: function(item, html) { Ext.get(item).insertFirst(Ext.Element.create({ cls: this.headerClsShortCache, html: html })); }
Code:Ext.define.doAddHeader() at sencha-touch-all-debug.js:44659Ext.define.findGroupHeaderIndices() at sencha-touch-all-debug.js:44651Ext.define.doRefreshHeaders() at sencha-touch-all-debug.js:44385Ext.define.doFire() at sencha-touch-all-debug.js:12851Ext.define.fire() at sencha-touch-all-debug.js:12777Ext.define.doDispatchEvent() at sencha-touch-all-debug.js:18568Ext.define.dispatchEvent() at sencha-touch-all-debug.js:18539Ext.define.doFireEvent() at sencha-touch-all-debug.js:21070Ext.define.fireEvent() at sencha-touch-all-debug.js:21040Ext.define.loadRecords() at sencha-touch-all-debug.js:26966Ext.define.onProxyLoad() at sencha-touch-all-debug.js:26727Ext.define.processResponse() at sencha-touch-all-debug.js:22715(anonymous function)() at sencha-touch-all-debug.js:25310Ext.apply.callback() at sencha-touch-all-debug.js:5774Ext.define.onComplete() at sencha-touch-all-debug.js:22073Ext.define.onStateChange() at sencha-touch-all-debug.js:22024(anonymous function)() at sencha-touch-all-debug.js:1964
-
12 Dec 2011 9:46 AM #8Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,653
- Vote Rating
- 14
Thank you for the updated test case.
-
12 Dec 2011 11:22 AM #9
-
13 Dec 2011 6:31 AM #10
If you guys find a work around let me know please
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1233
in
2.0.


Reply With Quote
No problem, Thanks for the help!