-
19 Dec 2012 11:39 AM #1
Answered: [ExtJS 4.1.1a] can't create Ext.grid.Panel
Answered: [ExtJS 4.1.1a] can't create Ext.grid.Panel
I use this code
and get error:Code:Ext.onReady(function() { Ext.define('MyModel', { extend: 'Ext.data.Model', fields: [ {name: 'check', type: 'bool', convert: null, defaultValue: false}, {name: 'id', type: 'int', convert: null, defaultValue: undefined}, {name: 'title', type: 'string', convert: null, defaultValue: undefined}, {name: 'link', type: 'string', convert: null, defaultValue: undefined}, {name: 'index', type: 'int', convert: null, defaultValue: undefined} ] }); Ext.define('MyStore', { extend: 'Ext.data.ArrayStore', model: 'MyModel', data: [ [false, 1, 'Title', 'link', 5] ] }); Ext.define('Bookmarks', { extend: 'Ext.grid.Panel', requires: ['Ext.ux.CheckColumn'], store: 'MyStore', title: 'Title', columns: [ {text: 'text', dataIndex: 'check', xtype: 'checkcolumn'}, {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'} ] }); Ext.create('Ext.container.Viewport', { layout: { type: 'vbox', align: 'stretch' }, items: [Ext.create('Bookmarks')] }); });
in Chrome
1.png
in Firefox
2.png
What am I doing wrong?
-
Best Answer Posted by chramerCode:
Ext.define('Bookmarks', { extend: 'Ext.grid.Panel', store: Ext.create('MyStore'), title: 'Title', columns: [ {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'} ] });
-
19 Dec 2012 4:44 PM #2
XHR requests work only over HTTP. Put this code in a HTTP server, like Apache.
-
19 Dec 2012 9:22 PM #3
I moved the files to the server and removed the 'checkcolumn', because it was absent for some reason.
Now I get this error:Code:Ext.onReady(function() { Ext.define('MyModel', { extend: 'Ext.data.Model', fields: [ {name: 'check', type: 'bool', convert: null, defaultValue: false}, {name: 'id', type: 'int', convert: null, defaultValue: undefined}, {name: 'title', type: 'string', convert: null, defaultValue: undefined}, {name: 'link', type: 'string', convert: null, defaultValue: undefined}, {name: 'index', type: 'int', convert: null, defaultValue: undefined} ] }); Ext.define('MyStore', { extend: 'Ext.data.ArrayStore', model: 'MyModel', data: [ [false, 1, 'Title', 'link', 5] ] }); Ext.define('Bookmarks', { extend: 'Ext.grid.Panel', store: 'MyStore', title: 'Title', columns: [ {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'} ] }); Ext.create('Ext.container.Viewport', { layout: { type: 'vbox', align: 'stretch' }, items: [Ext.create('Bookmarks')] }); });
firefox
1.png
chrome
2.png
-
19 Dec 2012 11:02 PM #4
Code:Ext.define('Bookmarks', { extend: 'Ext.grid.Panel', store: Ext.create('MyStore'), title: 'Title', columns: [ {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'} ] });
-
19 Dec 2012 11:43 PM #5
-
20 Dec 2012 12:14 AM #6
By and by, if in your store definition you give the store class an alias of 'store.mystore' then you can also instantiate that store type using:
store: { type: 'mystore' }


Reply With Quote