EXT form

JS代码如下:

Ext.onReady(function() {

    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    /*
     * ================  Simple form  =======================
     */

    var simple = new Ext.form.Form({
        labelAlign: 'right',
        labelWidth: 75, // label settings here cascade unless overridden
        url:'/form',
        buttonAlign: 'center'
    });

    var simple_name = new Ext.form.TextField({
        fieldLabel: 'Name',
        name: 'name',
        width:175
    });

    var simple_title = new Ext.form.TextField({
        fieldLabel: 'Title',
        name: 'title',
        width:175
    });

    simple.fieldset(
    {legend:'Edit'},
            simple_name,
            simple_title
            )

    var simple_data = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({url: '/form/edit.jsp?id=10'}),
        reader: new Ext.data.JsonReader({}, [ 'id', 'name', 'title']),
        remoteSort: false
    });

    simple_data.on('load', function() {

        simple_name.setValue(simple_data.getAt(0).data.name);
        simple_title.setValue(simple_data.getAt(0).data.title);

        simple.addButton('Save', function() {
            if (simple.isValid()) {
                simple.submit({
                    params:{
                        action:'submit',
                        id:simple.getAt(0).data.id
                    },
                    waitMsg:'Saving...'
                });
            } else {
                Ext.MessageBox.alert('Errors', 'Please fix the errors noted.');
            }
        }, simple);

        simple.render('form-ct');

    });

    simple_data.load();

});

 

问题:simple_name.setValue(simple_data.getAt(0).data.name); 报异常,提示getAt(...)为空或不是有效对象。

 

你可能感兴趣的:(json,jsp,.net,prototype,ext)