SSRS和交互式排序在MVC4中工作

时间:2013-06-19 19:42:39

标签: asp.net asp.net-mvc-4 reporting-services ssrs-2008

我使用html渲染在mvc中实现了一个报告引擎。我必须根据通过render方法返回的元数据创建自定义分页功能。我现在正在考虑以相同的方式实现交互式排序,这看起来像是一项更艰巨的任务。对于html呈现的 HTML设备信息设置标题,似乎有一个名为 ActionScript 的设置。

的ActionScript(*) - 指定发生操作事件时要使用的JavaScript函数的名称,例如钻取或书签单击。如果指定了此参数,则操作事件将触发指定的JavaScript函数,而不是回发到服务器。

我的问题是有人使用过此功能吗?由于我在呈现报告后丢失了身份验证,因此我必须以某种方式在控制器中进行经过身份验证的回调。在我看来,在报告中添加用于排序的参数可能更容易,但是我想在报告中保持交互式排序。

- 编辑Solution1 ---

事实证明,上面脚本名称旁边的*表示在2012年ssrs之后,ActionScript参数正在折旧。因此,我决定不追求它。如果其他人偶然发现了这一点,那么我想到的最好的方法就是模拟交互式排序而不回发帖子如下:

报告

1. Add a parameter to the report SortField1
2. Add a Sort condition to the Tablix or group you wish to sort. Tablix-Sort Expressions
3. Set the expression of the sort to Fields(Paremeters!SortField1.Value).Value
4. Set the default value of parameter SortField1 to the default sort field
5. Set Allow Nulls of the parameter to true.
6. Add a image or label for each column you would like to sort by
7. Create a action for the element created in step 7 with code similar to
  ="javascript:void(reportSortRequest('ColumsFieldName'))"
 NOTE: Your view or view descendant will have need to have an identical function defined to accept the action 

在视图中

  1. 实现函数reportSortRequest(fieldName)。这应该设定 Model.SortField1并调用post返回控制器 重新呈现报告。
  2. 在Controller中(这是用于发送具有字段SortField1的模型的Ajax post back)

    1. 使用报告信息(包括SortField1。
    2. )调用渲染

      更新了可用于访问报告标记包装器的客户端脚本。

      ssrs标记生成的报表元素可以在视图中通过其标记进行访问。我发现以下内容将使用预定的ssrs包装元素 #oReportCell “:

      加载iframe:

      var frameContent = $("#myIFrame").contents();        
      var ssrsContentElement = frameContent.find("#oReportCell");
      

      加载div:

      var ssrsContentElement = $("#myDiv").find("#oReportCell");
      

      将html blob加载到框架或div中的功能。根据报告的配置方式,内容可以是临时文件的URL或html标记。

      function setReportContent(content, isUrl, renderInIFrame) {        
          if (isUrl) {
              if (renderInIFrame) {
                  $("#reportContent").html("<iframe id='reportFrame' sandbox='allow-same-origin allow-scripts' width='100%' height='300' scrolling='yes' onload='onReportFrameLoad();'\></iframe>");
                  $('#reportFrame').attr('src', content);               
              }
              else 
                  $("#reportContent").load(content);              
      
          }
          else {
              if (renderInIFrame) {
                  $("#reportContent").html("<iframe id='reportFrame' sandbox='allow-same-origin allow-scripts' width='100%' height='300' scrolling='yes' onload='onReportFrameLoad();'\></iframe>");               
                  $('#reportFrame').contents().find('html').html(content);
              }
              else      
                  $("#reportContent").html(content);            
          }
          if(!renderInIFrame)
              showReportWaitIndicator(false);
          $("#reportContent").show();
      }
      

      请注意,如果您希望将自动调整大小属性设置的报表图像设置为正确呈现,则必须打开allow-scripts以便ssrs调整大小js函数可以触发,请注意。

0 个答案:

没有答案
相关问题