2009-05-29 21 views
0

Reporting Servicesは、ユーザーがプラス記号をクリックして行グループを展開するたびにWebページを自動スクロールすることによって「役立つ」と考えられます。 Microsoft DLLをハックするのに間に合わず、誰もこの動作を停止する方法を知っていますか?展開時にReporting Servicesがアンカーに自動的にスクロールする

ネットを検索すると、this years-old thread discussing the same issueが見つかりましたが、回答はありませんでした。私はSOの友達がもう少し精通していると思っていました。

答えて

1

私はちょうど同じ問題にぶつかって、汚れた修正を施しました!レポートビューアコントロールを使用して、独自のASP.Netページでレポートを表示しています。それは私の外側のホストページにいくつかの追加のスクリプトを置くことができるので私を助けます。ここで私は何をしたのですか:

私は怠け者で、スクロールバーのy位置を取り除くために機能を乗っ取っているので、私のページにMaintainScrollPositionOnPostbackを入れました。

スクロールバーのY位置を50msごとに取得する間隔を設定しました。

イベントハンドラをSSRS IFrameのloadイベントにアタッチします。これにより、スクロールバーが以前の場所に戻されます。

SSRSがiframeのロードイベントをポストバックするとき。この時点で、SSRSはスクロールバーをうっかり調整しました。イベントハンドラが起動して戻ってきます!それはかなり嫌なことですが、仕事をします。

コード:

<script language="javascript"> 


    $(document).ready(function() { 

     $('iframe').load(function() { 
      resetScrollbar(); 
     }); 

    }); 

    var lastGoodScrollY = 0; 
    var interval = window.setInterval(getScrollY, 50); 

    function getScrollY() { 
     lastGoodScrollY = WebForm_GetScrollY(); 
    } 

    function resetScrollbar() { 
     window.scrollTo(0, lastGoodScrollY); 
    } 

</script> 
0

あなたがそれを行う方法を知っていれば、透明な溶液は、非常に簡単です。 ;あなたがしなければならないものをすべてのコード、次の追加された)

$('.A0')から "A0" はReportViewerコントロールに割り当てられたCSSクラス名です

<script type="text/javascript" language="javascript"> 

    $(document).ready(function() { 
     $('.A0').get(0).ClientController.CustomOnReportLoaded = function() { 
      this.m_reportObject.m_navigationId = null; 
     }; 
    }); 

</script> 

。参考のため

私はReportViewerコントロールを初期化する方法を貼り付けています:

のように、上記の例のために呼び出され
protected void InitializeReportViewer(string ID) 
    { 
     string reportsPath = ConfigGetter.GetReportsPath(); 
     string reportingServerUrl = ConfigGetter.GetReportingServerUrl(); 

     Instance = new ReportViewer(); 
     Instance.ID = ID; 
     Instance.CssClass += ID; 
     Instance.ProcessingMode = ProcessingMode.Remote; 
     Instance.ServerReport.ReportServerUrl = new Uri(reportingServerUrl); 
     Instance.ServerReport.ReportPath = reportsPath + Config.Filename; 
     Instance.Enabled = true; 
     Instance.InternalBorderStyle = BorderStyle.None; 
     Instance.EnableViewState = true; 
     if (Config.AutomaticSize) 
     { 
      Instance.AsyncRendering = false; 
      Instance.SizeToReportContent = true; 
     } 
     else 
     { 
      Instance.Width = Config.Width; 
      Instance.Height = Config.Height; 
     } 


     Instance.ShowParameterPrompts = false; 
     Instance.ShowToolBar = false; 

     SetParameters(); 
    } 

:それが動作する理由、

説明以下
InitializeReportViewer("A0"); 

ReportViewerコントロールを多くのjavascriptコードを生成します。これには次のものが含まれます。

function OnLoadReport(reloadDocMap) 
{ 
    this.m_clientController.OnReportLoaded(this, reloadDocMap); 

    if (null != this.m_navigationId && this.m_navigationId != "") 
     window.location.replace("#" + this.m_navigationId); 

    if (this.m_autoRefreshAction != null) 
     setTimeout(this.m_autoRefreshAction, this.m_autoRefreshInterval); 
} 
RSReport.prototype.OnLoadReport = OnLoadReport; 


function OnReportLoaded(reportObject, reloadDocMap) 
{ 
    this.m_reportObject = reportObject; 
    this.CurrentPage = reportObject.m_pageNumber; 
    this.TotalPages = reportObject.m_totalPages; 
    this.m_searchStartPage = reportObject.m_searchStartPage; 

    // Update the client side page number so that it is available to the server object 
    // if it was changed asynchronously. 
    var clientCurrentPage = GetControl(this.m_clientCurrentPageID); 
    if (clientCurrentPage != null) 
     clientCurrentPage.value = this.CurrentPage; 

    // If there is a document map, display it 
    if (this.HasDocumentMap()) 
    { 
     // This method is called each time the report loads. This happens 
     // for page navigations and report actions. For many of these cases, 
     // the doc map didn't change, so don't reload it. 
     if (reloadDocMap) 
     { 
      if (this.CanDisplayBuiltInDocMap() && this.m_docMapUrl != "") 
      { 
       var docMapReportFrame = frames[this.m_docMapReportFrameID]; 
       docMapReportFrame.frames["docmap"].location.replace(this.m_docMapUrl); 
      } 

      this.CustomOnReloadDocMap(); 
     } 

     if (this.m_docMapVisible && this.CanDisplayBuiltInDocMap()) 
      this.SetDocMapVisibility(true); 
    } 

    this.CustomOnReportLoaded(); 
} 

迷惑なスクロールがあるため、コードのこの部分は次のとおりです。

if (null != this.m_navigationId && this.m_navigationId != "") 
     window.location.replace("#" + this.m_navigationId); 

だから我々はnullにthis.m_navigationIdを設定する必要があります。 どこ?

コード部分this.m_clientController.OnReportLoadedが呼び出される前に、メソッドCustomOnReportLoaded()の呼び出しが終了したので、このメソッドではm_navigationIdにnullを設定する必要があります。 そして、我々はそれをやっている。 Voila!

0

ReportViewerコントロール10.0.30319.1で使用している場合に役立ちます。プライベートであると考えられている_ReportAreaに触れ​​て、いくつかのシナリオで必要とされるかもしれないScrollToTarget関数をすべて排除するので、それほどきれいではありません。別の方法は、コントロールにアクセスすることでReportPageのこの関数と\ NavigationIdプロパティにアクセスすることですが、正確なコントロールIDを知る必要があります。私の場合は、rswebのクライアント側IDから作成されたreportViewerDivId_ctl09です。 ReportViewer Asp.Netコントロール。

$(window).load(function() { 

    if (Microsoft && Microsoft.Reporting && Microsoft.Reporting.WebFormsClient) { 
     var rpp = Microsoft.Reporting.WebFormsClient._ReportArea; 
     if (rpp && rpp.prototype) { 
      rpp.prototype.ScrollToTarget = function() { }; 
     } 
    } 
}); 

例2:

/* DOESN'T WORK!*/ 
var rp = $get('reportViewerDivId_ctl09_ReportControl'); /* rp.control is ReportPage */ 
rp[0].control.NavigationId = null; 
/*THE BELOW WORKED*/ 
var ra = $('#reportViewerDivId_ctl09'); /*ra[0].control is ReportArea*/ 
if (ra[0] && ra[0].control && ra[0].control.ScrollToTarget) { 
    ra[0].control.ScrollToTarget = function() { }; /*overriding the function so that anoying scroll on Sort doesn't happen */ 
} 
1

だけoverright ReportViewerWebForm.aspxへのReportViewer JSネイティブScrollToTarget機能: 第二の例に

例1を参照してください

$(document).ready(function() { 
    Microsoft.Reporting.WebFormsClient._ReportArea.prototype.ScrollToTarget = function(){}; 
}); 
+0

清掃をし、それIE11とChromeで動作します。私にとって完璧!答えとしてマークする必要があります。 –

関連する問題