我从数据库获得了数据 是这种形式
{"code":"datadict2","id":4,"name":"数据字典2","parentId":4}
想要显示在dataDictTabPanel = Ext.extend(Ext.FormPanel,{
 //定义构造器
constructor: function(){
var dataDictId = new Ext.form.TextField({
id: 'dataDictId',
name : 'dataDictId',
fieldLabel: '数据字典ID',
anchor : '90%'
});  
var dataDictName = new Ext.form.TextField({
id: 'dataDictName',
name : 'dataDictName',
fieldLabel: '数据字典名称',
anchor : '90%'
}); 
var dataDictCode = new Ext.form.TextField({
id: 'dataDictCode',
name : 'dataDictCode',
fieldLabel: '数据字典编码',
anchor : '90%'
}); 
dataDictTabPanel.superclass.constructor.call(this,{
labelAlign: "right",
buttonAlign: "right",
frame: true,
bodyStyle: "padding:0 0",
autoScroll: true,
items: [{
layout: "column",
items: [{
columnWidth: 1,
layout: 'form',
defaultType: 'textfield',
items: [dataDictId, dataDictName, dataDictCode]
}]
}]
});

 }
    });
原本用的是这种方式var json = response.responseText;
         var json = eval("("+json+")");
     Ext.getCmp('dataDictId').setValue(json.id);
     Ext.getCmp('dataDictName').setValue(json.name);
     Ext.getCmp('dataDictCode').setValue(json.code);
但是涉及到重用的问题 有bug,想要使用var record = this.lawExpMaintenanceGridPanel.getSelectionModel().getSelected();
 this.showWin("edit");
 //表单加载数据
 this.lawExpMaintenanceFp.form.loadRecord(record);这种record形式 但是不知道怎么把从转换成 record 的 求大侠们帮帮忙 真的很急

解决方案 »

  1.   

    你想干啥?ajax的record显示出来?
      

  2.   

    恩 是的 我用的 
    Ext.getCmp('dataDictId').setValue(json.id);
                        Ext.getCmp('dataDictName').setValue(json.name);
                        Ext.getCmp('dataDictCode').setValue(json.code);
    的话 ,当我同时打开多个formpanel的时候,使用id的bug就出现了,不能这么写
      

  3.   

    我这样写了 报错说 对象不支持此属性和方法DictInfoPanel = function(node, grid){
        //获得右侧tab对象
        Ext.Ajax.request({
    waitMsg : '读取数据',
    url : "/datadict/DataDictServlet?parameter="+node.id,
    method : "GET",
    callback : function(args, success, response) {
         var json = response.responseText;
             var json = eval("("+json+")");
         //Ext.getCmp('dataDictName').setValue(json.name);
         //Ext.getCmp('dataDictCode').setValue(json.code);
    if(success){
    var panel = Ext.getCmp("dataDictCenterPanel");
    panel.findField('dataDictName').setValue(json.name);
    panel.findField('dataDictCode').setValue(json.code);
    var tab = panel.findById(node.id);
    if(!tab){
        tab = panel.add({
        id: node.id,
        xtype:"panel",
        title:node.text,
        closable:true,
        layout:"fit",
        items:[grid]
         });
    }
    panel.setActiveTab(tab);
    }
    },
    scope: this
    });
        }
      

  4.   

    var json = JSON.parse(response.responseText);试试
      

  5.   

    这样写么? 然后怎么处理json 呢?DictInfoPanel = function(node, grid){
        //获得右侧tab对象
        Ext.Ajax.request({
    waitMsg : '读取数据',
    url : "/datadict/DataDictServlet?parameter="+node.id,
    method : "GET",
    callback : function(args, success, response) {
        var json = JSON.parse(response.responseText);
         //var json = response.responseText;
             var json = eval("("+json+")");
         //Ext.getCmp('dataDictName').setValue(json.name);
         //Ext.getCmp('dataDictCode').setValue(json.code);
    if(success){
    var panel = Ext.getCmp("dataDictCenterPanel");
    //panel.findField('dataDictName').setValue(json.name);
    //panel.findField('dataDictCode').setValue(json.code);
    var tab = panel.findById(node.id);
    if(!tab){
        tab = panel.add({
        id: node.id,
        xtype:"panel",
        title:node.text,
        closable:true,
        layout:"fit",
        items:[grid]
         });
    }
    panel.setActiveTab(tab);
    }
    },
    scope: this
    });
        }