1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    17
    Vote Rating
    0
    cs0ip is on a distinguished road

      0  

    Default 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
    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')]
      });  
    });
    and get error:
    in Chrome
    1.png

    in Firefox
    2.png

    What am I doing wrong?

  2. Code:
      Ext.define('Bookmarks', {
        extend: 'Ext.grid.Panel',
        store: Ext.create('MyStore'),
        title: 'Title',
        columns: [
          {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'}
        ]  
      });

  3. #2
    Sencha User
    Join Date
    Feb 2011
    Posts
    6
    Vote Rating
    0
    nferreira is on a distinguished road

      0  

    Default


    XHR requests work only over HTTP. Put this code in a HTTP server, like Apache.

  4. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    17
    Vote Rating
    0
    cs0ip is on a distinguished road

      0  

    Default


    I moved the files to the server and removed the 'checkcolumn', because it was absent for some reason.

    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')]
      });  
    });
    Now I get this error:

    firefox
    1.png

    chrome
    2.png

  5. #4
    Sencha User chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    203
    Answers
    42
    Vote Rating
    10
    chramer will become famous soon enough

      1  

    Default


    Code:
      Ext.define('Bookmarks', {
        extend: 'Ext.grid.Panel',
        store: Ext.create('MyStore'),
        title: 'Title',
        columns: [
          {text: 'title', xtype: 'templatecolumn', tpl: '{title}<br>{link}'}
        ]  
      });

  6. #5
    Sencha User
    Join Date
    Dec 2012
    Posts
    17
    Vote Rating
    0
    cs0ip is on a distinguished road

      0  

    Default


    chramer, many thanks, it worked.

  7. #6
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    5,349
    Answers
    429
    Vote Rating
    198
    slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of slemmon has much to be proud of

      0  

    Default


    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' }