Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rally 应用程序SDK 2中的打印功能_Rally - Fatal编程技术网

Rally 应用程序SDK 2中的打印功能

Rally 应用程序SDK 2中的打印功能,rally,Rally,我想向App SDK 2自定义应用程序添加打印功能,该应用程序在gear图标下显示网格和打印选项,但打印页面为空。您是否有打印网格的应用程序示例?找到的网格应用程序示例已修改为包含打印功能: <!DOCTYPE html> <html> <head> <title>GridExample</title> <script type="text/javascript" src="/apps/2.0rc1/sdk.js

我想向App SDK 2自定义应用程序添加打印功能,该应用程序在gear图标下显示网格和打印选项,但打印页面为空。您是否有打印网格的应用程序示例?

找到的网格应用程序示例已修改为包含打印功能:

<!DOCTYPE html>
<html>
<head>
    <title>GridExample</title>

    <script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function () {
            Ext.define('CustomApp', {
                extend: 'Rally.app.App',
                componentCls: 'app',

                launch: function() {
                    Rally.data.ModelFactory.getModel({
                        type: 'UserStory',
                        success: function(model) {
                            this.grid = this.add({
                                xtype: 'rallygrid',
                                itemId: 'grid',
                                model: model,
                                columnCfgs: [
                                    'FormattedID',
                                    'Name',
                                    'Owner'
                                ],
                                storeConfig: {
                                    filters: [
                                        {
                                            property: 'ScheduleState',
                                            operator: '=',
                                            value: 'Defined'
                                        }
                                    ]
                                }
                            });
                        },
                        scope: this
                    });
                },
                getOptions: function() {
                    return [
                        {
                            text: 'Print',
                            handler: this._onButtonPressed,
                            scope: this
                        }
                    ];
                },

                _onButtonPressed: function() {
                    options = "toolbar=1,menubar=1,scrollbars=yes,scrolling=yes,resizable=yes,width=1000,height=500";

                    var css = document.getElementsByTagName('style')[0].innerHTML;
                    var title = "User Stories";
                    var printWindow = window.open('', '', options);

                    var doc = printWindow.document;

                    var grid = this.down('#grid');

                    doc.write('<html><head>' + '<style>' + css + '</style><title>' + title + '</title>');
                    doc.write('</head><body class="landscape">');
                    doc.write('<p>My Grid: ' + title + '</p><br />');
                    doc.write(grid.getEl().dom.innerHTML);
                    doc.write('</body></html>');
                    doc.close();

                    this._injectCSS(printWindow);

                    printWindow.print();

                },
                _injectCSS: function(printWindow){
                    //find all the stylesheets on the current page and inject them into the new page
                    Ext.each(Ext.query('link'), function(stylesheet){
                        this._injectContent('', 'link', {
                            rel: 'stylesheet',
                            href: stylesheet.href,
                            type: 'text/css'
                        }, printWindow.document.getElementsByTagName('head')[0], printWindow);
                    }, this);
                },
                _injectContent: function(html, elementType, attributes, container, printWindow){
                    elementType = elementType || 'div';
                    container = container || printWindow.document.getElementsByTagName('body')[0];

                    var element = printWindow.document.createElement(elementType);

                    Ext.Object.each(attributes, function(key, value){
                        if (key === 'class') {
                            element.className = value;
                        } else {
                            element.setAttribute(key, value);
                        }
                    });

                    if(html){
                        element.innerHTML = html;
                    }

                    return container.appendChild(element);
                }
            });

            Rally.launchApp('CustomApp', {
                name:"GridExample"
                //parentRepos:""
            });

        });
    </script>

    <style type="text/css">
        .app {
            /* Add app styles here */
        }
    </style>

</head>
<body></body>
</html>

网格示例
Rally.onReady(函数(){
Ext.define('CustomApp'{
扩展:“Rally.app.app”,
组件CLS:“应用程序”,
启动:函数(){
Rally.data.ModelFactory.getModel({
键入:“UserStory”,
成功:功能(模型){
this.grid=this.add({
xtype:“rallygrid”,
itemId:'网格',
模型:模型,
专栏CFGS:[
'格式化ID',
“姓名”,
“所有者”
],
storeConfig:{
过滤器:[
{
属性:“ScheduleState”,
运算符:'=',
值:“已定义”
}
]
}
});
},
范围:本
});
},
getOptions:function(){
返回[
{
文本:“打印”,
处理者:这个。按下按钮,
范围:本
}
];
},
_onButtonPressed:function(){
选项=“工具栏=1,菜单栏=1,滚动条=yes,滚动条=yes,可调整大小=yes,宽度=1000,高度=500”;
var css=document.getElementsByTagName('style')[0].innerHTML;
var title=“用户故事”;
var printWindow=window.open(“”,,,选项);
var doc=printWindow.document;
var grid=this.down(“#grid”);
文件写入(“”+“”+css+“”+title+“”);
文件写入(“”);
文档写入(“我的网格:”+title+”


); doc.write(grid.getEl().dom.innerHTML); 文件写入(“”); doc.close(); 这是CSS(打印窗口); printWindow.print(); }, _injectCSS:函数(打印窗口){ //找到当前页面上的所有样式表并将它们注入新页面 Ext.each(Ext.query('link')、函数(样式表){ 此._包含内容(“”,'链接'{ rel:'样式表', href:stylesheet.href, 键入:“text/css” },printWindow.document.getElementsByTagName('head')[0],printWindow); },这个); }, _injectContent:函数(html、elementType、属性、容器、printWindow){ elementType=elementType | |‘div’; container=container | | printWindow.document.getElementsByTagName('body')[0]; var element=printWindow.document.createElement(elementType); Ext.Object.each(属性、函数(键、值){ 如果(键=='class'){ element.className=值; }否则{ setAttribute(键、值); } }); 如果(html){ element.innerHTML=html; } 返回容器.appendChild(元素); } }); Rally.launchApp('CustomApp'{ 名称:“GridExample” //家长报告:“ }); }); .app{ /*在此处添加应用程序样式*/ }
FWIW,我们可能还将创建一个插件,用于打印2.0 SDK GA的应用程序,其中包括上述答案中的许多复杂性(\u onButtonPressed、\u injectContent和\u injectCSS)。我们已经在核心产品中为页面提供了这一功能——只需稍微修改和扩展,就可以更广泛地与SDK 2应用程序一起使用