Javascript 如何将数据传递到弹出窗口以及如何在弹出窗口中读取数据
我在点击actioncolumn时调用弹出窗口 如果我想通过record.get('firstname'),那么怎么做呢 同时如何在afterrender中读取发送的数据 你可以照这个做-Javascript 如何将数据传递到弹出窗口以及如何在弹出窗口中读取数据,javascript,extjs,extjs5,Javascript,Extjs,Extjs5,我在点击actioncolumn时调用弹出窗口 如果我想通过record.get('firstname'),那么怎么做呢 同时如何在afterrender中读取发送的数据 你可以照这个做- handler: function (view, rowIndex, colIndex, item, e, record, row) { var infoWin=Ext.widget('Info'); infoWin.firstName=record.get('firstname');
handler: function (view, rowIndex, colIndex, item, e, record, row) {
var infoWin=Ext.widget('Info');
infoWin.firstName=record.get('firstname');
infoWin.show();
}
var infoForm = Ext.define('App.view.Report.Info', {
extend: 'Ext.window.Window',
listeners: {
afterrender: function (winObj) {
var firstName=winObj.firstName;
}
}
因为在创建Info实例之后,它只是一个对象,您可以添加新的属性运行时。使用下面的代码将任何键值传递给小部件
Ext.widget('Info',{
'firstname' : record.get('firstname')
}).show();
稍后,您可以通过“this.firstname”在afterrender函数中使用它。您可以在小部件中使用formpanel,并使用
form.loadRecord(record)
在formelements中轻松加载数据。以下是一个例子:
备选方案:
handler: function(grid, rowIndex, colIndex) {
var record = grid.getStore().getAt(rowIndex);
Ext.create('App.view.Report.Info', {
record: record
}).show();
}
小部件渲染后:
Ext.define('App.view.Report.Info', {
extend: 'Ext.window.Window',
listeners: {
afterrender: function () {
if (this.record) {
console.log(this.record);
}
}
}
handler: function(grid, rowIndex, colIndex) {
var record = grid.getStore().getAt(rowIndex);
Ext.create('App.view.Report.Info', {
record: record
}).show();
}
Ext.define('App.view.Report.Info', {
extend: 'Ext.window.Window',
listeners: {
afterrender: function () {
if (this.record) {
console.log(this.record);
}
}
}