ExtJs没有't将数据加载到窗体
ExtJs doesn't load data to a form
这是我的型号
Ext.define('Contact', {
extend : 'Ext.data.Model',
fields : [ {
name : 'first',
mapping : 'name.first'
}, {
name : 'last',
mapping : 'name.last'
}, 'company', 'email', {
name : 'dob',
type : 'date',
dateFormat : 'm/d/Y'
} ]
});
这是我的商店
var store = Ext
.create(
'Ext.data.Store',
{
// alert("inside")
// id: 'store',
model : 'Contact',
proxy : {
type : 'ajax',
url : 'urlForJson',
reader : 'json',
root : 'contact'
},
autoLoad : true
});
这是我的表单面板
Ext.onReady(function() {
var formPanel = Ext.create('Ext.form.Panel', {
title : 'Simple Form with FieldSets',
labelWidth : 75,
// url : 'save-form.php',
frame : true,
bodyStyle : 'padding:5px 5px 0',
width : 340,
bodyPadding : 5,
layout : 'anchor', // arrange fieldsets side by side
items : [ {
xtype : 'fieldset',
title : 'Contact Information',
defaultType : 'textfield',
defaults : {
width : 280
},
items : [ {
fieldLabel : 'First Name',
emptyText : 'First Name',
name : 'first'
}, {
fieldLabel : 'Last Name',
emptyText : 'Last Name',
name : 'last'
}, {
fieldLabel : 'Company',
name : 'company'
}, {
fieldLabel : 'Email',
name : 'email',
vtype : 'email'
}, {
xtype : 'datefield',
fieldLabel : 'Date of Birth',
name : 'dob',
allowBlank : false,
maxValue : new Date()
} ]
} ],
buttons : [ {
text : 'Load',
handler : function() {
formPanel.getForm().load({
url : 'xml-form-data.xml',
waitMsg : 'Loading...'
});
}
}, {
text : 'Submit',
disabled : true,
formBind : true,
handler : function() {
this.up('form').getForm().submit({
url : 'xml-form-errors.xml',
submitEmptyText : false,
waitMsg : 'Saving Data...'
});
}
} ],
renderTo : Ext.getBody()
});
var record = store.getAt(0);
formPanel.getForm().loadRecord(record);
}
);
但这不是从存储器加载数据,还有当我把这条线
'formPanel.getForm().loadRecord(record);'
它也给了我这个错误"Uncaught TypeError:无法调用未定义的方法"getData"希望任何人都能帮助我
似乎记录未定义。你能和console.log(record)
确认一下吗。
如果是这种情况,请参阅加载事件:
例如
var store = Ext.create(
'Ext.data.Store',
{
// alert("inside")
// id: 'store',
model : 'Contact',
proxy : {
type : 'ajax',
url : 'urlForJson',
reader : 'json',
root : 'contact'
},
autoLoad : false,
listeners: {
load: function(store, records) {
var record = store.getAt(0);
formPanel.getForm().loadRecord(record);
}
}
}
);
然后在表单面板呈现后调用store.load()。还要确保formPanel在加载事件回调中可见。如果它不可见,请将id添加到面板并使用Ext.get(formId)
一次只能显示一组数据项的东西不需要数据存储。
Json格式也可能存在问题。Json格式应包含success属性和数据属性。请参考以下链接以获取参考
http://docs.sencha.com/extjs/3.4.0/#/api/Ext.form.Action.Load
您的存储中应该有预先加载值的记录。您可以通过store.load()或声明性的autoLoad:true来达到这一点(当您刚开始使用ExtJS执行流时,这种方式可能会导致未发现的问题)。
try:
formPanel.loadRecord(record);
相关文章:
- 将HTML表格导出到excel时,无法将数据加载到excel文件中
- 如何将本地json数据加载到Extjs数据模型中
- FancyTree JS+Backbone.JS-将数据加载到FancyTree时出现问题
- 将数据加载到使用JSON返回的表单字段时出现问题
- 将基本CSV数据加载到D3
- 如何将JSON数据加载到Jqgrid中
- 点击事件时将新的JSON数据加载到Angular中
- 如何使用输入数据加载新的extjs图表
- 读取外部local.txt文件以将数据加载到数组中
- 将数据加载到地图上的更好解决方案
- 将谷歌地理编码(从url)数据加载到javascript变量中
- 按钮在第一次成功的 ajax 数据加载后不起作用
- Jquery 工具提示未随 AJAX 数据加载一起显示
- 将 json 数据加载到 CycleJS 应用程序中
- 将图像数据加载到Angularjs中
- 页面加载前的Angular JS数据加载
- 将数据加载到存储后,Extjs组合框为空
- 将从服务器获取的数据加载到输入文本表单中
- 从 txt 加载数组,将数据加载到 html 中
- 如何将PostgreSQL数据加载到HTML/JS中