0
不能填充字段这里是我的模型:从Ext.data.store
Ext.define('Email', {
extend: 'Ext.data.Model',
idProperty: 'emailid',
fields: [
{ name: 'emailid', type: 'int' },
{ name: 'emailsubject', type: 'string', useNull: true },
{ name: 'emailbody', type: 'string', useNull: true },
{ name: 'emailto', type: 'string', useNull: true },
{ name: 'emailfrom', type: 'string', useNull: true },
]
});
和DataStore:
var EmailDataStore = {
getDetailStore: function(aid) {
var options = {
autoLoad: true,
autoSync: true,
pageSize: 1,
remoteFilter: true,
remoteGroup: true,
remoteSort: true,
model: 'Email',
proxy: {
type: 'ajax',
url: 'datastores/datastore-email.asp?action=details&auditid=' + aid,
reader: {
type: 'json',
root: 'emailDetails'
}
}
};
if (typeof (options2) != 'undefined') {
options = Ext.merge(options, options2);
}
var detailStore = Ext.create('Ext.data.Store', options);
return detailStore;
}
}
我将不包括ASP,因为JSON是适当地返回数据。但是,在这个代码下位,
...
PortalEmailGrid.prototype.detailStore = null;
PortalEmailGrid.prototype.showEmailDetails = function (id) {
var self = this;
//alert(id);
self.detailStore = EmailDataStore.getDetailStore(id);
//view store at this state - object appears to exist with the returned record in it
console.log(self.detailStore);
var firstItem = self.detailStore.first();
//undefined here
console.log(firstItem);
//count is zero, but i can see the object in the console log above
alert('detailStore count: ' + self.detailStore.count());
var win = Ext.create('Ext.window.Window', {
title: 'Email Details',
store: self.detailStore,
height: 400,
width: 800,
bodyPadding: 4,
items: [
{
xtype: 'textfield',
name: 'tofield',
dataIndex: 'emailto',
fieldLabel: 'To'
},
{
xtype: 'textfield',
name: 'subjectfield',
dataIndex: 'emailsubject',
fieldLabel: 'Subject'
}
]
});
win.show();
}
我不能等领域与detailStore
的数据填充。但是当我登录self.detailStore
时,在Firebug中,我可以看到对象及其细节。 self.detailStore.count()
显示为零,但根据控制台,数据应该在那里。我怀疑由于这种差异,这些字段没有填入dataIndex
信息。另外,以前的代码块被称为是:
var selected = self.grid.selModel.selected;
var id = selected.items[0].raw.emailid;
//var status = selected.items[0].raw.status;
PortalEmailGrid.prototype.showEmailDetails(id);
你能看到任何理由数据不会从数据存储加载?
好真棒。这就说得通了。我正在尝试实现它。你可以发布一个例子吗?我刚刚被扔进煎茶,而且真的很生锈,用我的javascript:/ 当我完成时,我会接受你的答案。谢谢。 – 2013-02-13 22:39:28
用一个例子更新了OP。 – 2013-02-13 23:24:40
好吧,我明白了。但是我想在加载之后执行的操作是使用'dataIndex'填充字段。我尝试在回调函数中放置'win.Show()',但仍然没有数据。对不起,这个东西超级新手:/ – 2013-02-13 23:51:05