Results 1 to 4 of 4

Thread: GridPanel using a defined Store Problem

  1. #1
    Sencha User
    Join Date
    Dec 2009
    Posts
    80
    Answers
    1
    Vote Rating
    1
      0  

    Default Answered: GridPanel using a defined Store Problem

    I can't get this one working.
    I have to use the Ext.define for store, so its global.

    I get: "TypeError: item is undefined"

    using:

    Code:
    Ext.define('js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid', {
       extend: 'Ext.data.Model', 
       fields: [{
          type: 'string', 
          name: 'id'
       },{
          type: 'string', 
          name: 'displayField'
       }]
    });
    
    
    Ext.define('js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',{
       extend: "Ext.data.Store",
       storeId: "testdata",
       proxy:new Ext.data.proxy.Memory({
          model:'js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',
          reader:new Ext.data.reader.Json({})
       }),
       model:'js_model_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid',
       data:[{
          id:1,
          displayField:'Vienna'
       },{
          id:2,
          displayField:'London'
       },{
          id:3,
          displayField:'New York'
       }],
       remoteSort:false
    });
    
    new Ext.grid.Panel({
       id:'viewport.tab.tests_ui_objects_Ext_Mixed__form.fieldset.grid',
       autoScroll:true,
       xtype:'grid',
       closable:false,
       title:'grid datasource',
       autoHeight:true,
       columns:[{
          id:'viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid_id',
          width:40,
          sortable:true,
          dataIndex:'id',
          text:'id'
       },{
          id:'viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid_displayField',
          width:120,
          sortable:true,
          dataIndex:'displayField',
          text:'city',
          editor:{
             allowBlanke: false
          }
       }],
       forceFit:true,
       store:'testdata',
       loadMask:true,
       name:'grid',
       renderTo: Ext.getCmp("viewport.tab.form")
    });

  2. Some constructive feedback

    1. Your class names are bad. Your store is 'js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid', your name should be descriptive but short. You should be able to glance at it and tell what it is.
    2. id should only be used for debugging, you have it on everything and relying on it will be hard to change it later on.


    So the issue I saw is that your store isn't put in the StoreManager. If you change this line in your grid it will work:

    Code:
    store:'testdata',
    to

    Code:
    store: new js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid(),

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,307
    Answers
    3992
    Vote Rating
    1478
      0  

    Default

    Some constructive feedback

    1. Your class names are bad. Your store is 'js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid', your name should be descriptive but short. You should be able to glance at it and tell what it is.
    2. id should only be used for debugging, you have it on everything and relying on it will be hard to change it later on.


    So the issue I saw is that your store isn't put in the StoreManager. If you change this line in your grid it will work:

    Code:
    store:'testdata',
    to

    Code:
    store: new js_store_viewport_tab_tests_ui_objects_Ext_Mixed__form_fieldset_grid(),
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Dec 2009
    Posts
    80
    Answers
    1
    Vote Rating
    1
      0  

    Default

    big thx

    its working now

  5. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,307
    Answers
    3992
    Vote Rating
    1478
      0  

    Default

    That's because you're using Ext.getCmp which returns a component on the renderTo config which expects a DOM element or the id of a DOM element
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •