Hello Team,
Please am using angular controllerJS in my MVC application and bootstrap template to print transactions after sales,
but in the process of printing, the template sidebar and the invoice print together and want i want to do is to hide the sidebar
function GetAllPrintSalesRecord() {
debugger;
const urlParams = new URLSearchParams(window.location.search);
const OrderNo = urlParams.get('OrderNo');
.then(function (response) {
var data = response.data.modifiedData;
$scope.PrintSalesRecordList = data;
$scope.Total = response.data.total;
$scope.DiscountTotal = response.data.discount;
$scope.VatTotal = response.data.tax;
debugger
if ($scope.$$phase) {
$scope.$apply();
}
});
}
}]);
}).call(angular);
//Print Script
$('#invoice-printed').click(function () {
$('body').css('visibility', 'hidden');
$('#accordionSidebar').css('display', 'none');
$('.panel-body').css('visibility', 'visible');
$('#exampleInputUser').css('display', 'none');
window.print();
$('#accordionSidebar').css('display', '');
$('body').css('visibility', 'visible');
});

Vishal JoshiRank #377 · 6.7K reputationPosted Oct 21, 2023, 1:35 AM EDT
Hello Emmanuel,
Replace the below code with the function 'GetAllPrintSalesRecord()'.
function GetAllPrintSalesRecord() { const urlParams = new URLSearchParams(window.location.search); const OrderNo = urlParams.get('OrderNo'); .then(function (response) { var data = response.data.modifiedData; $scope.PrintSalesRecordList = data; $scope.Total = response.data.total; $scope.DiscountTotal = response.data.discount; $scope.VatTotal = response.data.tax; if ($scope.$$phase) { $scope.$apply(); } $('#accordionSidebar').css('display', 'none'); $('.panel-body').css('visibility', 'visible'); $('#exampleInputUser').css('display', 'none'); window.print(); $('#accordionSidebar').css('display', ''); $('body').css('visibility', 'visible'); }); } }]); }).call(angular);Thanks
Vishal Joshi
Emmmanuel FIADUFERank #947 · 2.2K reputationPosted Oct 21, 2023, 5:10 AM EDT
Thank you Vishal and Mohammed for your support
Tahir AnsariRank #366 · 6.8K reputationPosted Oct 21, 2023, 12:51 AM EDT
In your HTML template, you can create a separate print CSS to hide the sidebar when printing:
Modify your script to handle the printing action
$(document).ready(function () { // Print Script $('#invoice-printed').click(function () { $('body').css('visibility', 'hidden'); $('#accordionSidebar').css('display', 'none'); $('.panel-body').css('visibility', 'visible'); $('#exampleInputUser').css('display', 'none'); // Trigger the print action window.print(); // Restore the original visibility and display settings $('#accordionSidebar').css('display', ''); $('body').css('visibility', 'visible'); $('#exampleInputUser').css('display', ''); }); });the code is wrapped in a
$(document).readyfunction to ensure it runs when the document is fully loaded. It hides the sidebar, prints the page, and then restores the visibility and display settings after printing.Please make sure to include the above CSS and script in the appropriate places within your HTML file, and ensure that the
#invoice-printedelement corresponds to the button or link that triggers the printing action.