Javascript extjs:将变量传递到FormPanel

Javascript extjs:将变量传递到FormPanel,javascript,extjs,openlayers,Javascript,Extjs,Openlayers,我有一个函数: function saveToJ(feature) { var str = new OpenLayers.Format.GeoJSON(out_options).write(feature, true); str = str.replace(/,/g, ', '); strObj = Ext.decode(str); if(strObj.properties.name == null) { ... } else {

我有一个函数:

function saveToJ(feature) {
    var str = new OpenLayers.Format.GeoJSON(out_options).write(feature, true);
    str = str.replace(/,/g, ', ');
    strObj = Ext.decode(str);
    if(strObj.properties.name == null) {
        ...
    } else {
        if(!win) {
            win = new Ext.Window({
                title : "Edit",
                items : [editPanel],
                closeAction : 'hide'
            });
        }
        win.show();
        }
    }
}
和一个小组:

var editPanel = new Ext.form.FormPanel({
    width : 400,
    defaults : {
        width : 230
    },
    defaultType : 'textfield',

    items : [{
        fieldLabel : 'Name',
        name : 'name',
        allowBlank : false,
    }],

    buttons : [editSaveBtn, editDeleteBtn]

});
我想做的是使用
strObj.properties.name
作为面板上字段的
值。
但是
value:strObj.properties.name
给出了一个错误,
strObj
未定义

strObj
saveToJ
函数之外声明


我做错了什么?

很简单,只需使用:


editPanel.getForm().findField('name').setValue(strObj.properties.name)

在尝试打开窗口之前,是否确定strObj本身不为空?如果它已经在范围内,则不必将其传递给Ext.form就可以使用它。我会使用调试器并确保它不是空的。

谢谢,帮助我理解<当呈现
editPanel
时,code>strObj
实际上是空的,所以我必须传递它。