La solution claire est assez simple, si vous savez comment le faire. ;)
Tout ce que vous avez à faire est d'ajouter le code suivant:
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('.A0').get(0).ClientController.CustomOnReportLoaded = function() {
this.m_reportObject.m_navigationId = null;
};
});
</script>
où "A0" de $('.A0')
est le nom de classe css attribué à un contrôle ReportViewer.
Pour référence, je suis méthode coller l'initialisation contrôle 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();
}
qui est invoqué par exemple ci-dessus comme:
InitializeReportViewer("A0");
Ci-dessous l'explication, pourquoi cela fonctionne:
contrôle ReportViewer génère beaucoup de code javascript, qui contient entre autres les suivants:
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();
}
défilement Annoying est à cause de cette partie du code:
if (null != this.m_navigationId && this.m_navigationId != "")
window.location.replace("#" + this.m_navigationId);
Nous avons donc besoin de mettre this.m_navigationId
à null. Où?
Avant cette partie du code this.m_clientController.OnReportLoaded
méthode est invoquée, et à la fin est l'invocation de la méthode CustomOnReportLoaded()
, donc nous avons juste besoin de définir null pour m_navigationId
dans cette méthode. Et nous le faisons. Voila!
propre et fonctionne dans IE11 et Chrome. Parfait pour moi! Devrait être marqué comme la réponse. –