1. #1
    Ext User Yoda's Avatar
    Join Date
    Sep 2009
    Posts
    8
    Vote Rating
    0
    Yoda is on a distinguished road

      0  

    Exclamation Can't LOAD data into my JSONStore.

    Can't LOAD data into my JSONStore.


    Code:
    <html>
    
    <head>
    <title>EXT JS: Test Project</title>
    <link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all.css" />
    <style>
        .milton-icon {
            background: url(img/user_gray.png) no-repeat;
        }
    </style>
    <script src="lib/extjs/adapter/ext/ext-base.js"></script>
    <script src="lib/extjs/ext-all-debug.js"></script>
    <script>
            var proxy = new Ext.data.HttpProxy({
                url: 'data/genres.html'
            });
            
            var reader = new Ext.data.JsonReader({
                fields: ['id', 'genre_name'],
                root: 'rows'
            });
            
            var store = new Ext.data.Store({ 
                proxy: proxy,
                reader: reader
            });
            
            store.load();
        Ext.onReady(function(){
            Ext.QuickTips.init();
            
            Ext.form.VTypes['nameVal'] = /^([A-Z]{1})[A-Za-z\-]+([A-Z]{1})[A-Za-z\-]+$/;
            Ext.form.VTypes['nameMask'] = /[A-Za-z\- ]/;
            Ext.form.VTypes['nameText'] = 'In-valid Director Name.';
            Ext.form.VTypes['name'] = function(v){
                return Ext.form.VTypes['nameVal'].test(v);
            }
            
            var movie_form = new Ext.FormPanel({
                url: 'movie-form-submit.php',
                renderTo: document.body,
                frame: true,
                title: 'Movie Information Form',
                width: 250,
                items: [{
                    xtype: 'textfield',
                    fieldLabel: 'Title',
                    name: 'title',
                    allowBlank: false,
                    vtype: 'alpha',
                    listeners: {
                        specialkey: function(f,e){
                            if (e.getKey() == e.ENTER) {
                            movie_form.getForm().submit();
                            }
                        }
                    }
                },{
                    xtype: 'textfield',
                    fieldLabel: 'Director',
                    name: 'director',
                    allowBlank: false,
                    vtype: 'name'
                },{
                    xtype: 'datefield',
                    fieldLabel: 'Released',
                    name: 'released',
                    disabledDays: [1,2,3,4,5]
                },{
                    xtype: 'radio',
                    fieldLabel: 'Filmed In',
                    name: 'filmed_in',
                    boxLabel: 'Color'
                },{
                    xtype: 'radio',
                    hideLabel: false,
                    labelSeparator: '',
                    name: 'filmed_in',
                    boxLabel: 'Black & White'
                },{
                    xtype: 'checkbox',
                    fieldLabel: 'Bad Movie',
                    name: 'bad_movie'
                },{
                    xtype: 'combo',
                    name: 'genre',
                    fieldLabel: 'Genre',
                    store: store,
                    displayField:'genre_name',
                    width: 120
                },{
                    xtype: 'htmleditor',
                    name: 'description',
                    hideLabel: true,
                    labelSeparator: '',
                    height: 100,
                    anchor: '100%'
                }],
                buttons: [{
                    text: 'Save',
                    handler: function(){
                            movie_form.getForm().submit({
                            success: function(f,a){
                            Ext.Msg.alert('Success', 'It worked');
                        },
                            failure: function(f,a){
                            Ext.Msg.alert('Warning', 'Error');
                            }
                        });
                    }
                    }, {
                    text: 'Reset',
                    handler: function(){
                    movie_form.getForm().reset();
                    }
                }]
            });
        });
    </script>
    </head>
    
    <body>
    
    
    </body>
    </html>


    Here is my server side json response:

    Code:
    {"rows":[{"id":1,"genre_name":"Comedy"},{"id":2,"genre_name":"Horror"},{"id":3,"genre_name":"Suspense"}]}


    i'm trying to load this data into my combo-box(drop-down list)...

    somehow...nothing happens...i figured that something is wrong with my store...

    can anyone help me with this??? im really really new to EXT JS..........

  2. #2
    Sencha User
    Join Date
    Apr 2008
    Location
    Hong Kong
    Posts
    171
    Vote Rating
    0
    jarlau is on a distinguished road

      0  

    Default


    are you running this on the web server? or just locally?

  3. #3

Thread Participants: 2