extjs - 如何将表单值传递到新窗口?
问题描述
我有一个需要在新窗口中打印的表格。我可以传递表单的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 传递到新窗口?我很感激对此的任何建议。谢谢!
解决方案
如果您想将这些值传递给 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>');
推荐阅读
- c++ - Fixed_alpha_shape_3() 会破坏或修改原始三角测量吗?
- javascript - 如何在 Javascript 中为数组创建键?
- python - 如果相同的元素在 Python 数据类型(字符串/列表/元组)中引用相同的对象,那么如何确定变量的大小?
- javascript - 使用 createjs 系列的 preload.js 调用函数后音频不播放
- image - 设置新 src 时 Nativescript 调整图像大小?
- react-native - React Native View 不显示任何内容
- php - 如何使用 Symfony 4 中的事件处理异常?
- javascript - this.map.set(key,value) 函数在 angualr 6 typescript 2.9.2 中不起作用
- html - Booststrap 表插入模数后断裂
- django - Django:无法创建通用外键对象