我有一个需要在新窗口中打印的表格。我可以传递表单的innerHTML,但似乎无法获取值。这是示例代码:
print: function(){
var formPanel = Ext.getCmp('formPanelId');
var formValues = formPanel.getValues(); //this has data but it does not load on the new Window
var myWindow = window.open('', '', 'width=200,height=100');
myWindow.document.write('<html><head>');
myWindow.document.write('<title>' + 'Title' + '</title>');
myWindow.document.write('<link rel="Stylesheet" type="text/css" href="http://dev.sencha.com/deploy/ext-4.0.1/resources/css/ext-all.css" />');
myWindow.document.write('<script type="text/javascript" src="http://dev.sencha.com/deploy/ext-4.0.1/bootstrap.js"></script>');
myWindow.document.write('</head><body>');
myWindow.document.write(formPanel.body.dom.innerHTML);
myWindow.document.write('</body></html>');
}
如何将formValues传递到新窗口?我对此表示感谢。谢谢!
答案 0 :(得分:0)
如果要将这些值传递给Ext.window.Window,可以在创建Ext窗口时简单地执行以下操作
print: function(){
var formPanel = Ext.getCmp('formPanelId');
var formValues = formPanel.getValues();
var myWindow = Ext.create('YourWinodw', {formPanelValues:formValues}); // now in myWindow there is property formPanelValues that hold that value
}
如果您像上面那样使用普通的window.document.write,则需要立即按照以下步骤编写值
myWindow.document.write('<html><head>');
myWindow.document.write('<title>' + formValues['fieldName'] + '</title>');