Dart语言:打印报告 [英] Dart Language: printing reports

查看:638
本文介绍了Dart语言:打印报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Dart上列印报表。



基本上,这是活动流程: b
$ b


  1. 用户点击报告按钮。

  2. 创建了新的浏览器窗口。

  3. 相关数据放在新窗口中。

当然,如果有任何API,我会使用它。



到目前为止,我已经尝试创建一个新窗口,添加onMessage监听器,并调用postMessage对主类发送数据。然而,它没有工作。

/ p>

  var reportWindow; 
void createReportWindow(){
reportWindow = window.open(report.html,);
}
void sendMessage(String message){
reportWindow.postMessage(message,*);
}

报告Dart类

  void startListening(){
window.onMessage.listen((e) {
print(e.data.toString());
});
}


解决方案

更新



开始从报告窗口发送到 window.opener.postMessage(...),然后响应 (message.source作为WindowBase).postMessage(...)
这可能是 window.open 的返回值的错误(参见

原创



此单元测试中的代码会告诉您如何完成 https://github.com/dart-lang/core-elements/blob/master/test/core_media_query_test.dart



我打开来自加载其内容的新URL的窗口以及来自服务器的Dart脚本(当然也可以被编译为JavaScript)。打开的窗口通过 sendMessage 与主窗口通信。这在两个方向工作。



基本上第二个窗口是第二个Dart浏览器应用程序。



这可能不是你所看到的



在这一行 https://github.com/dart-lang/core-elements/blob/master/test/core_media_query_test.dart#L66 注释掉的代码可能符合您的要求。我创建了下面的解决方法,因为代码应该调整主窗口中的代码的第二个窗口,以测试< core-media-query> 元素工作btw。)。但我假设你只需要打开窗口,注释掉的代码应该做得很好。


I would like to know how to print reports on Dart.

Basically, this is the activity flow:

  1. User clicks "Report" button.
  2. New browser window is created.
  3. Related data gets placed in the new window.

Of course that if there's any API to do that, I would use it.

So far, I've tried to create a new window, add onMessage listener on it and call postMessage on the main class to send data. However, it didn't work. The message never gets to the other side (main > new browser window).

Main Dart Class

var reportWindow;
void createReportWindow() {
    reportWindow = window.open("report.html", "");
}
void sendMessage(String message) {
    reportWindow.postMessage(message, "*");
}

Report Dart Class (linked to report.html)

void startListening() {
    window.onMessage.listen((e) {
        print(e.data.toString());
    });
}

解决方案

Update

Start sending from the report window to window.opener.postMessage(...) and then respond to (message.source as WindowBase).postMessage(...). This is probably a bug with the return value of window.open (see http://dartbug.com/20216 for more details).

Original

The code in this unit test should show you how it can be done https://github.com/dart-lang/core-elements/blob/master/test/core_media_query_test.dart.

I open a window from a new URL that loads its content and a Dart script (can of course also be compiled to JavaScript) from the server. The opened window communicates with the main window by sendMessage. This works in both directions.

Basically the second window is a second Dart browser application.

This might not exactly be what you were looking for but your requirement could realized this way I guess.

At this line https://github.com/dart-lang/core-elements/blob/master/test/core_media_query_test.dart#L66 the commented out code would probably fit for your requirement. I created the workaround below because the code is supposed to resize the second window from code in the main window to test the <core-media-query> element (doesn't work either btw.). But I assume you just need to open the window and the commented out code should do exactly that just fine.

这篇关于Dart语言:打印报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆