-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alan Juden
committed
Feb 28, 2017
1 parent
c741c6e
commit 4cbda98
Showing
14 changed files
with
389 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
350 changes: 185 additions & 165 deletions
350
nuget.netcore/content/Views/Report/ReportViewer.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,166 +1,186 @@ | ||
@model AlanJuden.MvcReportViewer.ReportViewerModel | ||
@using AlanJuden.MvcReportViewer | ||
|
||
@{ | ||
ViewBag.Title = "ReportViewer"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>ReportViewer</h2> | ||
|
||
@section AdditionalHeadContent { | ||
<link type="text/css" rel="stylesheet" href="~/css/select2.min.css" /> | ||
<link type="text/css" rel="stylesheet" href="~/css/select2-bootstrap.min.css" /> | ||
<link type="text/css" rel="stylesheet" href="~/css/mvcreportviewer-bootstrap.css" /> | ||
<script type="text/javascript" src="~/js/select2.min.4.0.3.js"></script> | ||
<script type="text/javascript" src="~/js/jquery.highlight-5.js"></script> | ||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
$('select').select2(); | ||
$('.FirstPage, .ViewReport, .Refresh').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
viewReportPage(1); | ||
} | ||
}); | ||
$('.PreviousPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerCurrentPage').val()) - 1; | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('.NextPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerCurrentPage').val()) + 1; | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('.LastPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerTotalPages').text()); | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('#ReportViewerCurrentPage').change(function () { | ||
var page = $(this).val(); | ||
viewReportPage(page); | ||
}); | ||
$('.ExportXml, .ExportCsv, .ExportPdf, .ExportMhtml, .ExportExcelOpenXml, .ExportTiff, .ExportWordOpenXml').click(function () { | ||
exportReport($(this)); | ||
}); | ||
$('#ReportViewerSearchText').change(function () { | ||
findText(); | ||
}); | ||
$('.FindTextButton').click(function () { | ||
findText(); | ||
}); | ||
$('.Print').click(function () { | ||
printReport(); | ||
}); | ||
}); | ||
function showLoadingProgress(message) { | ||
$('.ReportViewerContent').hide(); | ||
$('.ReportViewerContentContainer').append('<div class="loadingContainer"><div style="margin: 0 auto; width: 100%; text-align: center; vertical-align: middle;"><h2><i class="glyphicon glyphicon-cog gly-spin"></i>' + message + '</h2></div></div>'); | ||
} | ||
function hideLoadingProgress() { | ||
$('.loadingContainer').remove(); | ||
$('.ReportViewerContent').show(); | ||
} | ||
function printReport() { | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
window.open("/Report/PrintReport/[email protected]&" + urlParams, "_blank"); | ||
} | ||
function findText() { | ||
$('.ReportViewerContent').removeHighlight(); | ||
var searchText = $("#ReportViewerSearchText").val(); | ||
if (searchText != undefined && searchText != null && searchText != "") { | ||
showLoadingProgress('Searching Report...'); | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var page = parseInt($('#ReportViewerCurrentPage').val()) + 1; | ||
$.get("/Report/FindStringInReport/[email protected]&page=" + page + "&" + urlParams).done(function (data) { | ||
if (data > 0) { | ||
viewReportPage(data); | ||
} | ||
$('.ReportViewerContent').highlight(searchText); | ||
hideLoadingProgress(); | ||
}); | ||
} | ||
} | ||
function viewReportPage(page) { | ||
showLoadingProgress('Loading Report Page...'); | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var totalPages = parseInt($('#ReportViewerTotalPages').text()); | ||
if (page == undefined || page == null || page < 1) { | ||
page = 1; | ||
} else if (page > totalPages) { | ||
page = totalPages; | ||
} | ||
$.get("/Report/ViewReportPage/[email protected]&page=" + page + "&" + urlParams) | ||
.done(function (data) { | ||
updateReportContent(data); | ||
hideLoadingProgress(); | ||
}) | ||
.fail(function (data) { | ||
$('.ReportViewerContent').html("<div class='ReportViewerError'>Report failed to load, check report parameters...</div>"); | ||
hideLoadingProgress(); | ||
}); | ||
} | ||
function exportReport(element) { | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var format = $(element).attr('class').replace("Export", ""); | ||
window.location.href = "/Report/ExportReport/[email protected]&format=" + format + "&" + urlParams; | ||
} | ||
function updateReportContent(data) { | ||
if (data != undefined && data != null) { | ||
$('#ReportViewerCurrentPage').val(data.CurrentPage); | ||
$('#ReportViewerTotalPages').text(data.TotalPages); | ||
$('.ReportViewerContent').html(data.Content); | ||
if (data.TotalPages <= 1) { | ||
$('.FirstPage').attr('disabled', true); | ||
$('.PreviousPage').attr('disabled', true); | ||
$('.NextPage').attr('disabled', true); | ||
$('.LastPage').attr('disabled', true); | ||
} else { | ||
$('.FirstPage').attr('disabled', false); | ||
$('.PreviousPage').attr('disabled', false); | ||
$('.NextPage').attr('disabled', false); | ||
$('.LastPage').attr('disabled', false); | ||
} | ||
} | ||
} | ||
</script> | ||
} | ||
|
||
@section Content { | ||
@Html.RenderReportViewer(Model) | ||
@model AlanJuden.MvcReportViewer.ReportViewerModel | ||
@using AlanJuden.MvcReportViewer | ||
|
||
@{ | ||
ViewBag.Title = "ReportViewer"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>ReportViewer</h2> | ||
|
||
@section AdditionalHeadContent { | ||
<link type="text/css" rel="stylesheet" href="~/css/select2.min.css" /> | ||
<link type="text/css" rel="stylesheet" href="~/css/select2-bootstrap.min.css" /> | ||
<link type="text/css" rel="stylesheet" href="~/css/mvcreportviewer-bootstrap.css" /> | ||
<style type="text/css"> | ||
.row { | ||
margin-left: 0; | ||
margin-right: 0; | ||
} | ||
</style> | ||
<script type="text/javascript" src="~/js/select2.min.4.0.3.js"></script> | ||
<script type="text/javascript" src="~/js/jquery.highlight-5.js"></script> | ||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
$('select').select2(); | ||
$('.FirstPage, .ViewReport, .Refresh').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
viewReportPage(1); | ||
} | ||
}); | ||
$('.PreviousPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerCurrentPage').val()) - 1; | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('.NextPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerCurrentPage').val()) + 1; | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('.LastPage').click(function () { | ||
if (!$(this).attr('disabled')) { | ||
var page = parseInt($('#ReportViewerTotalPages').text()); | ||
viewReportPage(page); | ||
} | ||
}); | ||
$('#ReportViewerCurrentPage').change(function () { | ||
var page = $(this).val(); | ||
viewReportPage(page); | ||
}); | ||
$('.ExportXml, .ExportCsv, .ExportPdf, .ExportMhtml, .ExportExcelOpenXml, .ExportTiff, .ExportWordOpenXml').click(function () { | ||
exportReport($(this)); | ||
}); | ||
$('#ReportViewerSearchText').on("keypress", function (e) { | ||
if (e.keyCode == 13) { | ||
// Cancel the default action on keypress event | ||
e.preventDefault(); | ||
findText(); | ||
} | ||
}); | ||
$('.FindTextButton').click(function () { | ||
findText(); | ||
}); | ||
$('.Print').click(function () { | ||
printReport(); | ||
}); | ||
}); | ||
function showLoadingProgress(message) { | ||
hideLoadingProgress(); | ||
$('.ReportViewerContent').hide(); | ||
$('.ReportViewerContentContainer').append('<div class="loadingContainer"><div style="margin: 0 auto; width: 100%; text-align: center; vertical-align: middle;"><h2><i class="glyphicon glyphicon-refresh gly-spin"></i>' + message + '</h2></div></div>'); | ||
} | ||
function hideLoadingProgress() { | ||
$('.loadingContainer').remove(); | ||
$('.ReportViewerContent').show(); | ||
} | ||
function printReport() { | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
window.open("/Report/PrintReport/[email protected]()&" + urlParams, "_blank"); | ||
} | ||
function findText() { | ||
$('.ReportViewerContent').removeHighlight(); | ||
var searchText = $("#ReportViewerSearchText").val(); | ||
if (searchText != undefined && searchText != null && searchText != "") { | ||
showLoadingProgress('Searching Report...'); | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var page = parseInt($('#ReportViewerCurrentPage').val()); | ||
$.get("/Report/FindStringInReport/[email protected]()&page=" + page + "&searchText=" + searchText + "&" + urlParams).done(function (data) { | ||
if (data > 0) { | ||
viewReportPage(data, function () { | ||
$('.ReportViewerContent').highlight(searchText); | ||
hideLoadingProgress(); | ||
}); | ||
} else { | ||
$('.ReportViewerContent').highlight(searchText); | ||
hideLoadingProgress(); | ||
} | ||
}); | ||
} | ||
} | ||
function viewReportPage(page, afterReportLoadedCallback) { | ||
showLoadingProgress('Loading Report Page...'); | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var totalPages = parseInt($('#ReportViewerTotalPages').text()); | ||
if (page == undefined || page == null || page < 1) { | ||
page = 1; | ||
} else if (page > totalPages) { | ||
page = totalPages; | ||
} | ||
$.get("/Report/ViewReportPage/[email protected]()&page=" + page + "&" + urlParams) | ||
.done(function (data) { | ||
updateReportContent(data); | ||
hideLoadingProgress(); | ||
if (afterReportLoadedCallback && typeof (afterReportLoadedCallback) == "function") { | ||
afterReportLoadedCallback(); | ||
} | ||
}) | ||
.fail(function (data) { | ||
$('.ReportViewerContent').html("<div class='ReportViewerError'>Report failed to load, check report parameters...</div>"); | ||
hideLoadingProgress(); | ||
}); | ||
} | ||
function exportReport(element) { | ||
var params = $('.ParametersContainer :input').serializeArray(); | ||
var urlParams = $.param(params); | ||
var format = $(element).attr('class').replace("Export", ""); | ||
window.location.href = "/Report/ExportReport/[email protected]()&format=" + format + "&" + urlParams; | ||
} | ||
function updateReportContent(data) { | ||
if (data != undefined && data != null) { | ||
$('#ReportViewerCurrentPage').val(data.CurrentPage); | ||
$('#ReportViewerTotalPages').text(data.TotalPages); | ||
$('.ReportViewerContent').html(data.Content); | ||
if (data.TotalPages <= 1) { | ||
$('.FirstPage').attr('disabled', true); | ||
$('.PreviousPage').attr('disabled', true); | ||
$('.NextPage').attr('disabled', true); | ||
$('.LastPage').attr('disabled', true); | ||
} else { | ||
$('.FirstPage').attr('disabled', false); | ||
$('.PreviousPage').attr('disabled', false); | ||
$('.NextPage').attr('disabled', false); | ||
$('.LastPage').attr('disabled', false); | ||
} | ||
} | ||
} | ||
</script> | ||
} | ||
|
||
@section Content { | ||
@Html.RenderReportViewer(Model) | ||
} |
Oops, something went wrong.