简体   繁体   中英

selectfield not loading on build

I am almost giving up. I've being trying for almost a month to develop an app using sencha touch 2.2.1 and sencha cmd 3.1.2.324. All works on development, but after create the production file (sencha app build) my selectfield do not load.

Actually I'd isolated all pages on the app and I am working just with few cards. From chrome I can check the webservice is called and return as expected. The console doesn't show any error, but the selectfield remain empty.

Any clue?

Panel:

     Ext.define('MySecondApp.view.Home', {
        extend: 'Ext.Panel',
        xtype: 'mg_home',
        config:
        {
           title:   'Home',
           id:      'tabHome',
           iconCls: 'info',
           layout:  'vbox',
           xtype:   'panel',
           items:
           [
              {docked: 'top',xtype: 'titlebar',title: 'Home'},
              {
                 xtype:         'selectfield',
                 name:          'selectMesHome',
                 id:            'selectMesHome',
                 action:        'selectMesHome',
                 label:         'Mes', /*TODO*/
                 scrollable:    true,
                 displayField:  'dc_data',
                 valueField:    'vl_data',
                 store:         'mesesHome'
              },
              {
                 xtype:         'panel',
                 id:            'home_content',
                 html:          'carregando...'
              }
           ]
        }
     });

model:

     Ext.define('MySecondApp.model.Meses', {
        extend: 'Ext.data.Model',
        config: {
           fields :
           [
              {name:'dc_data',  type:'string'},
              {name:'vl_data',  type:'string'}
           ]
        }
     });

store:

     Ext.define('MySecondApp.store.mesesHome', {
        extend: 'Ext.data.Store',
        storeId: 'mesesHomeStore',
        config: {
           model: 'MySecondApp.model.Meses',
           autoLoad: true,
           proxy:
           {
              type: 'ajax',
              url: 'http://www.meusgastos.com.br/touch/rest/meses.php',
              reader:
              {
                 type: 'json',
                 root: 'data'
              }
           }
        }
     });

ajax request some credentials previous saved (and tested, and working). The response will be:

     {
         "HEADER": [],
         "vl_atual": "201308",
         "data": [
             {
                 "dc_data": "Agosto/2013",
                 "vl_data": "201308"
             },
             {
                 "dc_data": "Julho/2013",
                 "vl_data": "201307"
             },
             {
                 "dc_data": "Junho/2013",
                 "vl_data": "201306"
             },
             {
                 "dc_data": "Maio/2013",
                 "vl_data": "201305"
             },
             {
                 "dc_data": "Abril/2013",
                 "vl_data": "201304"
             },
             {
                 "dc_data": "Março/2013",
                 "vl_data": "201303"
             }
         ]
     }

Make these changes and try again

In Store ( MySecondApp.store.mesesHome )

1) Put the storeId inside config

2) change reader root as rootProperty

So, store looks like this

 Ext.define('MySecondApp.store.mesesHome', {
    extend: 'Ext.data.Store',
    config: {
       storeId: 'mesesHomeStore',
       model: 'MySecondApp.model.Meses',
       autoLoad: true,
       proxy:
       {
          type: 'ajax',
          url: 'http://www.meusgastos.com.br/touch/rest/meses.php',
          reader:
          {
             type: 'json',
             rootProperty: 'data'
          }
       }
    }
 });

In view ( MySecondApp.view.Home )

This change is not necessary, But still i suggest you to do this.

Give storeId to store property of selectfield

          {
             xtype:         'selectfield',
             name:          'selectMesHome',
             id:            'selectMesHome',
             action:        'selectMesHome',
             label:         'Mes', /*TODO*/
             scrollable:    true,
             displayField:  'dc_data',
             valueField:    'vl_data',
             store:         'mesesHomeStore'
          },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM