【问题标题】:ExtJS 4.2 - Ext.ux.Printer library/class does not workExtJS 4.2 - Ext.ux.Printer 库/类不起作用
【发布时间】:2014-11-09 09:49:11
【问题描述】:

美好的一天。抱歉,我偶然发现了一个问题,在过去的几个小时里我似乎无法弄清楚。我下载了这个printing class,以便能够打印我在我的网络应用程序中拥有的表格。我将Ext.ux.Printer 文件夹复制到resources 内的scripts 文件夹中。文件路径类似于:resources/scripts/Ext.ux.Printer,并且资源文件夹与app 文件夹位于同一级别。

我的加载器看起来像:

Ext.Loader.setConfig({
    enabled: true,
    paths: {
        'Ext.ux.Printer': 'resources/scripts/Ext.ux.Printer/Printer'
    }
});

应用程序看起来像:

Ext.application({

    requires: [
        'Ext.Loader',
        'Ext.layout.container.Absolute',
        'resources.scripts.Notification',
        'Ext.layout.container.Column',
        'Ext.ux.Printer.Printer'
    ], //models, views, controllers, follow after

我尝试在我的代码中使用它:

Ext.ux.Printer.print(form);

但是,每当我尝试执行上面的代码行时,都会得到一个Uncaught TypeError: Cannot read property 'Printer' of undefined

谁能帮帮我?我是 ExtJS4 的初学者,我只是想按照我在互联网上看到的示例进行操作——我可能试图用我在网上看到的东西错误地调整我的代码。

非常感谢任何帮助,谢谢。

更新 1

在与下面的 Guilherme Lopes 讨论后,我们执行了以下步骤:

  1. 通过将 js 文件添加为 Sencha Architect 中的 js 资源来导入 js 文件。确保文件路径正确。
  2. 选中includeAfterAppJS 复选框。由于 Architect 中的一个错误,有时 JS 文件会在 ExtJS 之前添加。
  3. 打开index.html使用ext-all.js 而不是ext-dev.js。请注意,每次您保存项目时,Sencha Architect 都会覆盖/重置此文件。快速解决方法是转到项目设置并取消选中更新 index.html。
  4. 试试Ext.ux.Print.print(form);

【问题讨论】:

    标签: extjs extjs4 extjs4.2


    【解决方案1】:

    根据开发人员的说明,您应该使用主 html 文档导入脚本文件,就像使用 ExtJS 类一样(如果您不使用引导程序)。

    这些行应该在你导入 ExtJS 库后添加:

    <script type="text/javascript" src="Printer.js"></script>
    <script type="text/javascript" src="renderers/Base.js"></script>
    
    The library currently comes with renderers for Ext.grid.GridPanel, and Ext.tree.ColumnTree.
    These can be included as required:
    <script type="text/javascript" src="renderers/GridPanel.js"></script>
    <script type="text/javascript" src="renderers/ColumnTree.js"></script>
    

    您对 Ext.ux.Printer 的调用应该开始工作了。

    如果您使用 Architect,请单击添加外部 JS 文件:+ => 资源 => JS 资源 然后将 URL 更改为您需要的路径(对您要添加的每个文件执行此操作) * 我只是取消选中 x-compile 和 x-bootstrap

    【讨论】:

    • 检查生成的index.html 文件后,正在使用引导程序。我不确定我是否应该触摸这个文件。
    • 你在使用 Architect 吗?
    • 是的。煎茶架构师 3.1
    • 我已经为 Architect 添加了说明
    • 正式注明。会尝试。谢谢。
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 2013-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多