【问题标题】:Reportico : yii2 How to embed Links?Reportico : yii2 如何嵌入链接?
【发布时间】:2016-12-24 17:40:16
【问题描述】:

我创建了一个名为“atom”的 Reportico 项目和一个名为“Receipts”的报告,然后我在 ReportController 中创建了 action=receipts。 This是我跟着的教程:

控制器代码:

public function actionReceipts()
{
  return $this->render('receipts');
}

我创建了receipts.php

<?php

use yii\helpers\Html;
use yii\helpers\Url;

$this->title = Yii::t('app', 'Reports');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="report-index">



<div class="container">
<div class="row">
     <div class="col-sm-1">
     </div>
    <div class="col-sm-11">


     <?php 
       $reportico = \Yii::$app->getModule('reportico');
    $engine = $reportico->getReporticoEngine();        // Fetches reportico engine
    $engine->access_mode = "ONEREPORT";                // Allows access to single specified report
    $engine->initial_execute_mode = "PREPARE";         // Starts user in report criteria selection mode
    $engine->initial_project = "atom";            // Name of report project folder
    $engine->initial_report = "receipts";           // Name of report to run
    $engine->bootstrap_styles = "3";                   // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap
    $engine->force_reportico_mini_maintains = true;    // Often required
    $engine->bootstrap_preloaded = true;               // true if you dont need Reportico to load its own bootstrap
    $engine->clear_reportico_session = true;           // Normally required
    $engine->execute();  
    ?>
    </div>

</div>

</div>
</div>

我的代码应该打开

http://localhost/Atom/backend/web/index.php?r=report%2Freceipts 

当我尝试它时,我得到了我附上的图片

当我在 config.php define('SW_ADMIN_PASSWORD','1234'); 中输入密码时什么都没有显示。

我不需要强制用户输入密码!

我需要在 Criteria Entry Mode 中嵌入报告。

【问题讨论】:

    标签: php yii2 yii2-advanced-app reportico


    【解决方案1】:

    首先如果你不想提示输入密码,然后从config.php文件中取出密码或使用项目配置选项将其空白。如果你想保留它然后添加到代码中(在执行之前打电话)

    $engine-&gt;initial_project_password = "1234";

    其次,我认为这无济于事,因为您看到的是空白...您可以尝试上述选项之一来摆脱密码提示,然后看看它是否有效。如果您仍然得到空白,那么我们需要调查 ajax 调用。您是否无法进入您的网络浏览器调试网络选项卡并在按下某些东西时,记下发送到服务器的链接并查看响应?

    【讨论】:

    • 我从 config.php 中删除了它,但我仍然得到空白页!仍然要求输入密码。
    • 顺便说一句,当我打开“localhost/Atom/backend/web/index.php?r=reportico”时,密码消失了。无需密码即可打开仪表板。
    • 我得到了解决方案:它在配置项目中.. 我忘了添加主机名。或IP。
    【解决方案2】:

    你可以使用 url helper

    use yii\helpers\Url;
    
    
    echo '<a href="' . Url:to(['/report/receipts']) . 
                   '" type="button" class="btn  btn-block btn-default">Receipts</a>';
    

    你应该设置相关的动作

     $engine->initial_report = Url:to(['/report/receipts']);        // Name of report to run
    

    【讨论】:

    • 是的,我做到了,链接工作正常..但页面不能完美工作..我创建的报告工作但链接不起作用..我会添加更多图片。
    • 请更好地解释您的评论..“他报告我创建了工作但链接不起作用”是什么意思。使用相关代码和正确信息更新问题
    • 安装 Repotico 后,有类似仪表板的东西,您可以创建项目和报告,您可以测试它们报告这就是我所做的......然后有嵌入链接来报告这是我的问题我什么都没得到。
    • 如果您可以发布相关代码(不仅仅是简单链接)我可以看看
    • 我已经用一个简短的建议更新了答案..希望有用..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 2021-09-27
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    相关资源
    最近更新 更多