日期:2014-05-16  浏览次数:20643 次

急!Extjs 表单填充问题 - Web 开发 / Ajax
Ext.onReady(function(){

Ext.QuickTips.init();

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var fs = new Ext.FormPanel({
frame: true,
title:'jsomn Form',
labelAlign: 'right',
labelWidth: 85,
width:340,
waitMsgTarget: true,

// configure how to read the json Data
reader : new Ext.data.JsonReader({
success: 'success',
record : 'data'
}, [
{name: 'name', mapping:'name'}, // custom mapping
{name: 'sex', mapping:'sex'}
]),

items: [
new Ext.form.FieldSet({
title: 'Contact Information',
autoHeight: true,
defaultType: 'textfield',
items: [{
fieldLabel: 'sex',
name: 'name',
width:190
},{ 
fieldLabel: 'sex',
name: 'sex',
width:190
}
]
})
]
});
fs.form.load({url: 'resForm.jsp',method:'GET', waitMsg:'Loading' });

});
resForm.jsp代码:
<%out.print("{success:true,data:[{name:'Rooney',address:'Mu',loves:2,memo:'Tank'}]}");
%>
现在显示不出来 急求解决办法,或者给个例子

------解决方案--------------------
这个是官方的例子
JScript code

var myFormPanel = new Ext.form.FormPanel({
    title: 'Client and routing info',
    items: [{
        fieldLabel: 'Client',
        name: 'clientName'
    }, {
        fieldLabel: 'Port of loading',
        name: 'portOfLoading'
    }, {
        fieldLabel: 'Port of discharge',
        name: 'portOfDischarge'
    }]
});
myFormPanel.getForm().load({
    url: '/getRoutingInfo.php',
    params: {
        consignmentRef: myConsignmentRef
    },
    failure: function(form, action) {
        Ext.Msg.alert("Load failed", action.result.errorMessage);
    }
});