angularjs I need to print all page in paged ng-repeat - angularjs

I need to print (send to printer) all 100 element in my paged ng-repeat
while I display 20 element in the page
I tried to use AngularPrint but it didn't work because it print only one page
any idea please?
this is my code
<table class="table table-bordered">
<thead>
<tr class="info">
<th ng-click="sort('client')" class="col-md-1" rowspan="2" style="text-align: center; vertical-align: middle;">
Klant
<span class="glyphicon sort-icon" ng-show="sortKey=='client'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th class="col-md-2" colspan="2" style="text-align: center; vertical-align: middle;">
Total
</th>
<th ng-click="sort('difference')" class="col-md-1" rowspan="2" style="text-align: center; vertical-align: middle;">
Difference
<span class="glyphicon sort-icon" ng-show="sortKey=='difference'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('percentage')" class="col-md-1" rowspan="2" style="text-align: center; vertical-align: middle;">
Difference %
<span class="glyphicon sort-icon" ng-show="sortKey=='percentage'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
</tr>
<tr class="info">
<th ng-click="sort('firstYear')" class="col-md-1" style="text-align: center; vertical-align: middle;">
{{ criteria.firstYear }}
<span class="glyphicon sort-icon" ng-show="sortKey=='firstYear'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
<th ng-click="sort('secondYear')" class="col-md-1" style="text-align: center; vertical-align: middle;">
{{ criteria.secondYear }}
<span class="glyphicon sort-icon" ng-show="sortKey=='secondYear'"
ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
</th>
</tr>
</thead>
<tbody class="searchable">
<tr ng-repeat="stat in stats | orderBy:sortKey:reverse" ng-class="stat.total1 >= stat.total2 ? 'danger-row':'success-row'">
<td>{{ stat.companyAbbrev }}</td>
<td class="td-right">€ {{ stat.total1 | number : 2}}</td>
<td class="td-right">€ {{ stat.total2 | number : 2 }}</td>
<td class="td-right">{{ stat.difference | number : 2 }}</td>
<td class="td-right">{{ stat.percentage| number : 2 }} %</td>
</tr>
</tbody>
</table>

I don't know for sure but this sounds like a grid of elements? What are you using for your grid? I know that AngularUI Grid has print and export to excel capabilities and a lot of supporting documentation. It can also be a little bit daunting to implement due to it's scope.
To answer your comment in regards to print functionality check this link: exporting data tutorial When you click the menu button in the example and select export to pdf it opens up the pdf in a separate browser tab that you can save or print.

Related

angularjs smart table (st-table) issue with ngInclude

I had a page working fine with st-table in angularjs (1.8.x).
Ref: Smart Table Website or on Git Hub.
Because the page was becoming too big (HTML), as a quick fix I put the sections into diff HTML files and then used ng-include on main page. But since then the st-search stopped working.
Check the code:
<table class="table table-condense table-striped table-bordered" ng-hide="vmModelMg.currentModel.exclusionParts.length==0" st-safe-src="vmModelMg.currentModel.exclusionParts" st-table="dispExclPartsList">
<thead style="overflow-y:scroll;">
<tr>
<th colspan="2" style="width: 30%; padding-right: 10px;border-right:none;">
<a class="btn btn-primary pull-left" ng-click="vmModelMg.refreshExclusionPartsManual()">Refresh</a>
</th>
<th colspan="3" style="width: 35%;border-right:none;border-left:none;">
Show only Active? :
<!--'{{vmModelMg.isActiveModelFilterExPt}}'-->
<input type="checkbox" st-search="isActive" value="{{vmModelMg.isActiveModelFilterExPt}}" ng-model="vmModelMg.isActiveModelFilterExPt" ng-true-value="true" ng-false-value="" />
</th>
<th style="width: 35%;border-left:none;">
<a class="btn btn-primary pull-right" ng-click="vmModelMg.addNewExclusionPart()">Add new Exclusion Part</a>
</th>
</tr>
<tr>
<th style="width: 10%;"></th>
<th st-sort="partCode" style="width: 15%;">Part Code</th>
<th style="width: 15%;">Transmission Type</th>
<th st-sort="isActive" style="width: 15%;">Is Active?</th>
<th style="width: 45%;">Notes</th>
</tr>
</thead>
<tbody style="overflow-y:scroll;max-height:300px;">
<tr ng-show="dispExclPartsList.length==0">
<td colspan="5" style="width:100%;">
<div class="alert alert-info">
No Exclusion Parts found.
</div>
</td>
</tr>
<tr ng-repeat="exclPartRec in dispExclPartsList">
... td values here ...
</tr>
</tbody>
</table>
I included this using code below:
<ng-include src="'/Scripts/app/Views/manageModels.exclusionParts.html'"></ng-include>
Can someone please advise why if I paste this code in main page it works & if in the ngInclude it doesn't. Now, when I say it doesn't it doesn't show records when tab is loaded. If I click on "Show Active only" checkbox, the filter starts working. But, if same code is on single page, it shows records as soon as I load the tab.

Angularjs-probelm dont work $compile after get response of ajax

i created directive for making print page.this directive have template page that included button and print template(this have ngRepeat on Result object).print button was clicked fire "click" funciton in Controller of directive then ajax request send to server for get array of object that fill print tamplate.
Mainpage.html
<div ng-class="{'btn':true,'btn-warning':true,'disabled':disableBtn}" data-toggle="modal"
ng-click="getdetail=true;" data-target="#detailModal">order detail</div>
<print-order disable-btn="disableBtn" order="selectedItem"></print-order>
print.template.html
<a ng-click="ctrl.click()" ng-class="{'btn':true,'btn-info':true,'disabled':ctrl.disableBtn}" >
print
<i class="fa fa-print"></i>
</a>
<div id="printSection">
<table style="width: 100%;font:13px tahoma;" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th style="border-bottom: 3px solid black;">
<p>number: </p>
{{ctrl.order.fldTracking}}
</th>
<th>
<img src="/images/receipt-logo.png" alt="">
</th>
<th style="border-bottom: 3px solid black;">
<p>code :</p>
<p> {{ctrl.order.customer.fldMobilePhone}}
<br> {{ctrl.order.fldAtFA.split("-")[0]}}
</p>
</th>
</tr>
</thead>
<tbody>
<tr style="border-bottom: 3px solid black;">
<td colspan="3" style="padding: 10px;line-height: 20px;">
cutomer : {{ctrl.order.customerAddress.fldContactName }}
<br /> address: {{ctrl.order.customerAddress.fldAddress }}
<br/>mobile : {{ctrl.order.customerAddress.fldMobilePhone}}
<br/> phone : {{ctrl.order.customerAddress.fldTelephone}} </td>
</tr>
</tbody>
</table>
<h1>{{ctrl.title}}</h1>
<table dir="rtl" width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:20px;border-top:2px solid #000000;;border-bottom:2px solid #000000;border-color: #000000">
<tbody>
<tr>
<td width="40%" style="padding-right:10px;font-size: 10px" align="right">name</td>
<td width="20%" style="font-size: 10px" align="center">number</td>
<td width="20%" style="font-size: 10px" align="center">price</td>
<td width="25%" style="font-size: 10px" align="right">price</td>
</tr>
<tr ng-repeat="item in ctrl.Components track by $index">
<td style="padding-right:10px;font-size: 9px">
{{item.offer.fldTitle}}<br>
</td>
<td style="font-size: 12px" align="center">{{item.fldQty}}</td>
<td style="font-size: 10px" align="center">{{item.fldUnitPrice}}</td>
<td style="font-size: 10px;padding: 5px">{{item.fldTotalPrice}}</td>
</tr>
</tbody>
</table>
</div>
printdirective.js
myApp.directive("printOrder",["$window","orderService","$timeout","$compile",function($windows,orderService,$timeout,$compile){
return{
restrict:"AE",
bindToController:{
disableBtn:"=",
order:"="
},
templateUrl:"/Widgets/printOrder.template.html",
transclude: true,
scope:true,
controllerAs:"ctrl",
controller:function(){
this.click=function(){
var popupWinindow =$windows.open("", '_blank', 'width=300,height=500');
orderService.getOrderDetail(this.order.id)
.then(function(result){
this.Components=result;
popupWinindow.document.open();
var el=angular.element("#printSection")
$compile(el)(this);
$timeout(function(){
// console.log(el.html());
popupWinindow.document.write(
`<html>
<head></head>
<body style="direction: rtl;">`+el.html()+` </body>
</html>`);
popupWinindow.document.close();
},500)
});
}
},
}
}])
when i clicked on print button .id of order send to directive then detail of order request of server with ajax that this should fill "#printSection" of template by $compile but this dont binding and Components property is empty.
but this dont binding and Components property is empty.
You cannot call $compile with this, in your case $compile(el)(this);
this != scope
Use:
controller:function($scope){
$compile(el)($scope);
}
Small Demo
Is it typo? var el=angular.element("#printSection")
Did you mean something like:
var warapper = document.querySelector('#printSection');
angular.element(warapper); //...

how to loop through a table in selenium?

I am new to selenium and I have this question where I need to loop through a table and get the values in that table
<table>
<tr>
<td style="width:5px">
</td>
<td>
<table class="reportTable" id="Allocations">
<tbody>
<tr class="table_header">
<td style="width:5px;">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details">
</td>
<td style="width:33%">
Channel of Trade</td>
<td style="width:33%">
PILOT TRAVEL CENTE-122194-W/S - UNB Contract</td>
<td style="width:33%">
<span id="TruckLoading_10142602_Info" style="COLOR: white;text-decoration:underline;cursor:pointer">
Trucks loading - 0</span>
</td>
</tr>
<tr>
<td style="width:5px;">
</td>
<td colspan="3">
<table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1">
<tbody>
<tr class="productlabel2" align="left">
<td scope="col" style="width:5px;">
</td>
<td>
Product Details</td>
</tr>
<tr class="hdr2">
<td scope="col" style="width:5px;">
</td>
<td scope="col">
Fuel Type</td>
</tr>
<tr class="FuelTypeHeader">
<td style="width:5px;border:none" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img">
</td>
<td style="border-left:none;border-right:none; padding-left:3px">
<table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;">
<tbody>
<tr>
<td style="width:20em;">
<span>
DSL - LSD/ULSD</span>
</td>
<td style="width:60em;">
<span id="CVSpan">
<span style="margin-right:10px">
<span style="float:left;padding-top:3px">
Currently:</span>
<span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#00FF00;">
Available</span>
<span style="float:left; padding-top:3px">
<b>
30,839</b>
gallons remaining until Mon 8/1/2016 12:00:00 AM CDT</span>
</span>
</span>
</td>
<td align="right">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="">
<td style="width:5px;">
</td>
<td>
<table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1">
<tbody>
<tr class="table_header2">
<th scope="col">
Nominated Volume</th>
<th scope="col">
Allocation Period</th>
<th scope="col">
Allocation %</th>
<th scope="col">
Allocation Start Amt</th>
<th scope="col">
Allocation Lifted</th>
<th scope="col">
Allocation Remaining</th>
<th scope="col">
GPO Allowance</th>
<th scope="col" class="center width8em">
GPO Remaining</th>
<th scope="col">
Category Status</th>
<th scope="col">
Ratability Status</th>
<th scope="col">
Next Scheduled Refresh Date</th>
<th scope="col">
Reference ID</th>
</tr>
<tr class="tablerow2">
<td class="right width8em">
41,118</td>
<td class="center width10em">
Daily</td>
<td class="right">
75%</td>
<td class="right">
30,839</td>
<td class="right">
0</td>
<td class="right">
30,839</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#00FF00;">
Available</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
<tr class="tablerow2">
<td class="right width8em">
287,826</td>
<td class="center width10em">
Weekly</td>
<td class="right">
125%</td>
<td class="right">
359,783</td>
<td class="right">
114,083</td>
<td class="right">
245,700</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#00FF00;">
Available</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/4/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
<tr class="tablerow2">
<td class="right width8em">
1,233,540</td>
<td class="center width10em">
Monthly</td>
<td class="right">
115%</td>
<td class="right">
1,418,571</td>
<td class="right">
1,361,264</td>
<td class="right">
57,307</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#FFFF00;">
Low</td>
<td class="center" style="background-color:#00CC00;">
On Track</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="GPO_Row">
<td style="width:5px;">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="table_header">
<td style="width:5px;" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details">
</td>
<td style="width:33%">
Channel of Trade</td>
<td style="width:33%">
PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont</td>
<td style="width:33%">
<span id="TruckLoading_17049566_Info" style="COLOR: white;text-decoration:underline;cursor:pointer" onclick="GetTruckLoadingInformationJS(this,17049566);">
Trucks loading - 0</span>
</td>
</tr>
<tr>
<td style="width:5px;">
</td>
<td colspan="3">
<table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1">
<tbody>
<tr class="productlabel2" align="left">
<td scope="col" style="width:5px;">
</td>
<td>
Product Details</td>
</tr>
<tr class="hdr2">
<td scope="col" style="width:5px;">
</td>
<td scope="col">
Fuel Type</td>
</tr>
<tr class="FuelTypeHeader">
<td style="width:5px;border:none" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img">
</td>
<td style="border-left:none;border-right:none; padding-left:3px">
<table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;">
<tbody>
<tr>
<td style="width:20em;">
<span>
DSL - LSD/ULSD</span>
</td>
<td style="width:60em;">
<span id="CVSpan">
<span style="margin-right:10px">
<span style="float:left;padding-top:3px">
Currently:</span>
<span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#FF0000;">
Out</span>
<span style="float:left; padding-top:3px">
<b>
0</b>
gallons remaining until Mon 8/1/2016 12:00:00 AM CDT</span>
</span>
</span>
</td>
<td align="right">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="">
<td style="width:5px;">
</td>
<td>
<table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1">
<tbody>
<tr class="table_header2">
<th scope="col">
Nominated Volume</th>
<th scope="col">
Allocation Period</th>
<th scope="col">
Allocation %</th>
<th scope="col">
Allocation Start Amt</th>
<th scope="col">
Allocation Lifted</th>
<th scope="col">
Allocation Remaining</th>
<th scope="col">
GPO Allowance</th>
<th scope="col" class="center width8em">
GPO Remaining</th>
<th scope="col">
Category Status</th>
<th scope="col">
Ratability Status</th>
<th scope="col">
Next Scheduled Refresh Date</th>
<th scope="col">
Reference ID</th>
</tr>
<tr class="tablerow2">
<td class="right width8em">
0</td>
<td class="center width10em">
Custom 1 day(s)</td>
<td class="right">
100%</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#FF0000;">
Out</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
MERC-DSL</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="GPO_Row">
<td style="width:5px;">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
I wanted to know how to loop the table so i can get a contracts that's the " PILOT TRAVEL CENTE-122194-W/S - UNB Contract","PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont" and "UNB Spot" along with the data of the table also.
Thanks in advance.
Ok you didn't say nothing about the language you use so i will give you example in C#
//Init table element (in this case by tag name but better chose by id or Name)
IWebElement tableElement = driver.FindElement(By.TagName("table"));
//Init TR elements from table we found into list
IList<IWebElement> trCollection = tableElement.FindElements(By.TagName("tr"));
//define TD elements collection.
IList<IWebElement> tdCollection;
//loop every row in the table and init the columns to list
foreach(IWebElement element in trCollection)
{
tdCollection = element.FindElements(By.TagName("td"));
//now in the List you have all the columns of the row
string column1 = tdCollection[0].Text;
string column2 = tdCollection[1].Text;
...
}
if you use other language just change the syntax the logic is the same.

How to convert an existing table(Html) to jQuery datatable in AngularJS

Below is the html I have used to show data in the table, its working fine.
Now I want to convert it to jQuery Datatables.
HTML:-
<table cellpadding="3" class="table table-bordered">
<thead>
<tr class="success">
<th style="cursor: pointer;" ng-click="sort('DOB')"><b>DOB</b> <span class="glyphicon sort-icon" ng-show="sortKey=='DOB'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span></th>
<th style="cursor: pointer;" ng-click="sort('StateName')"><b>State</b> <span class="glyphicon sort-icon" ng-show="sortKey=='StateName'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span></th>
<th style="cursor: pointer;" ng-click="sort('FileId')"><b>Image</b> <span class="glyphicon sort-icon" ng-show="sortKey=='FileId'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span></th>
<th><b>Actions</b></th>
</tr>
</thead>
<tbody>
<tr dir-paginate="employee in employees|orderBy:sortKey:reverse|filter:search|itemsPerPage:5" ng-model="search">
<td>{{employee.DOB | date:'MM/dd/yyyy' }}
<td>{{employee.StateName}}
</td>
<td>
<img ng-src="UploadedFiles/{{employee.FilePath}}" class="img-circle" style="max-width: 50px" alt='Employee Image Missing' />
</td>
</tr>
</tbody>
</table>

Pop up calendar for date selection in selenium java

how to select date from calendar pop up? There's a text field which is in disabled mode. When you click on the calendar icon at the corner of the text field the calendar pops up which displays the current date. I need to select the date which is two years back. How do i go about doing that in selenium java?
below is the html code:
<div class="datepicker datepicker-dropdown dropdown-menu" style="display: block; top: 429.1px; left: 234.5px;">
<div class="datepicker-days" style="display: block;">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev" style="visibility: visible;">
<i class="icon-arrow-left"></i>
</th>
<th class="switch" colspan="5">February 2009</th>
<th class="next" style="visibility: visible;">
<i class="icon-arrow-right"></i>
</th>
</tr>
<tr>
<th class="dow">Su</th>
<th class="dow">Mo</th>
<th class="dow">Tu</th>
<th class="dow">We</th>
<th class="dow">Th</th>
<th class="dow">Fr</th>
<th class="dow">Sa</th>
</tr>
</thead>
<tbody>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
</tbody>
<tfoot>
</table>
</div>
<div class="datepicker-months" style="display: none;">
<table class="table-condensed">
<thead>
<tbody>
<tr>
<td colspan="7">
<span class="month">Jan</span>
<span class="month">Feb</span>
<span class="month">Mar</span>
<span class="month">Apr</span>
<span class="month">May</span>
<span class="month">Jun</span>
<span class="month">Jul</span>
<span class="month">Aug</span>
<span class="month">Sep</span>
<span class="month">Oct</span>
<span class="month">Nov</span>
<span class="month">Dec</span>
</td>
</tr>
</tbody>
<tfoot>
</table>
</div>
<div class="datepicker-years" style="display: none;">
</div>
use try catch statement
In try u can search for the element to be present in the page (any unique element related to the date to be selected)
In catch block you can click on the back button .
so in this case it will keep clicking on back/previous button in the calender to go to the previuos year .

Resources