- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
var search;
var searchdiv = $("#searchdiv");
var perPage = 3;
searchdiv.pagination({
itemsOnPage: perPage,
cssStyle: "light-theme",
onPageClick: function(pageNumber) {
var showFrom = perPage * (pageNumber - 1);
var showTo = showFrom + perPage;
search.hide()
.slice(showFrom, showTo).show();
}
});
function updateItems() {
search = $(".geoname");
searchdiv.pagination("updateItems", search.length);
var page = Math.min(
searchdiv.pagination("getCurrentPage"),
searchdiv.pagination("getPagesCount")
);
searchdiv.pagination("selectPage", page);
}
updateItems();
var geo = {
"geonames": [{
"lng": -99.12766456604,
"geonameId": 3530597,
"countrycode": "MX",
"name": "Mexiko-Stadt",
"fclName": "city, village,...",
"toponymName": "Mexico City",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Mexico_City",
"lat": 19.428472427036,
"fcl": "P",
"population": 12294193,
"fcode": "PPLC"
}, {
"lng": 116.397228240967,
"geonameId": 1816670,
"countrycode": "CN",
"name": "Peking",
"fclName": "city, village,...",
"toponymName": "Beijing",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Beijing",
"lat": 39.9074977414405,
"fcl": "P",
"population": 11716620,
"fcode": "PPLC"
}, {
"lng": 120.9822,
"geonameId": 1701668,
"countrycode": "PH",
"name": "Manila",
"fclName": "city, village,...",
"toponymName": "Manila",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Manila",
"lat": 14.6042,
"fcl": "P",
"population": 10444527,
"fcode": "PPLC"
}, {
"lng": 90.40743827819824,
"geonameId": 1185241,
"countrycode": "BD",
"name": "Dhaka",
"fclName": "city, village,...",
"toponymName": "Dhaka",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Dhaka",
"lat": 23.710395616597037,
"fcl": "P",
"population": 10356500,
"fcode": "PPLC"
}, {
"lng": 126.9784,
"geonameId": 1835848,
"countrycode": "KR",
"name": "Seoul",
"fclName": "city, village,...",
"toponymName": "Seoul",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Seoul",
"lat": 37.566,
"fcl": "P",
"population": 10349312,
"fcode": "PPLC"
}, {
"lng": 106.84513092041016,
"geonameId": 1642911,
"countrycode": "ID",
"name": "Jakarta",
"fclName": "city, village,...",
"toponymName": "Jakarta",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Jakarta",
"lat": -6.214623197035775,
"fcl": "P",
"population": 8540121,
"fcode": "PPLC"
}, {
"lng": 139.69171,
"geonameId": 1850147,
"countrycode": "JP",
"name": "Tokyo",
"fclName": "city, village,...",
"toponymName": "Tokyo",
"fcodeName": "capital of a political entity",
"wikipedia": "de.wikipedia.org/wiki/Tokyo",
"lat": 35.6895,
"fcl": "P",
"population": 8336599,
"fcode": "PPLC"
}, {
"lng": 121.531846,
"geonameId": 1668341,
"countrycode": "TW",
"name": "Taipeh",
"fclName": "city, village,...",
"toponymName": "Taipei",
"fcodeName": "capital of a political entity",
"wikipedia": "de.wikipedia.org/wiki/Taipei",
"lat": 25.047763,
"fcl": "P",
"population": 7871900,
"fcode": "PPLC"
}, {
"lng": -74.08175468444824,
"geonameId": 3688689,
"countrycode": "CO",
"name": "Bogotá",
"fclName": "city, village,...",
"toponymName": "Bogotá",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Bogot%C3%A1",
"lat": 4.609705849789108,
"fcl": "P",
"population": 7674366,
"fcode": "PPLC"
}, {
"lng": 114.157691001892,
"geonameId": 1819729,
"countrycode": "HK",
"name": "Hong Kong",
"fclName": "city, village,...",
"toponymName": "Hong Kong",
"fcodeName": "capital of a political entity",
"wikipedia": "en.wikipedia.org/wiki/Hong_Kong",
"lat": 22.2855225817732,
"fcl": "P",
"population": 7012738,
"fcode": "PPLC"
}]
}
geonames = geo.geonames;
var data = geonames;
for (var i = 0; i < data.length; i++) {
tr = $('<tr class=geoname/>');
if (data[i].geonameId) {
tr.append("<td id=''>" + data[i].name + "</td>");
tr.append("<td id=''>" + data[i].countrycode + "</td>");
tr.append("<td id=''>" + data[i].lng + "</td>");
tr.append("<td id=''>" + data[i].lat + "</td>");
tr.append("<td id=''>" + data[i].population + "</td>");
tr.append("<td id=''>" + data[i].geonameId + "</td>");
tr.append("<td id=''>" + "<a class=geonameview id=" + data[i].geonameId + " href='#' >View Details</a>" + "</td>");
} else {
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
tr.append("<td id=''></td>");
}
$("#geonames").append(tr);
}
updateItems();
function printpage() {
window.print();
}
@media print {
.dontprint {
display: none
}
body {
display: block;
}
}
body {
display: block;
}
<link type="text/css" rel="stylesheet" href="https://rawgit.com/flaviusmatis/simplePagination.js/master/simplePagination.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://rawgit.com/flaviusmatis/simplePagination.js/master/jquery.simplePagination.js"></script>
<table id="geonames" class="searchresult" border="1">
<tr id="">
<th>
Name
</th>
<th>
Country Code
</th>
<th>
Longitude
</th>
<th>
Latitude
</th>
<th>
Population
</th>
<th>
ID
</th>
<th>
Action
</th>
</tr>
</table>
<div id="searchdiv" class="dontprint"></div>
<button onclick="printpage()" class="dontprint" style="float: right">Print Preview</button>
使用
$('.printMe').click(function(){
window.print();
});
我可以打印整个屏幕。在我的屏幕上,我有一个使用 flaviusmatis Simple Pagination 分页的表格。所以我在 table 上有按钮。我加了
.dontprint{
display : none
}
对于我不需要打印的元素,包括分页中的按钮。
如果我有 50 个页面,那么点击和浪费时间太多了。
注意
我。我尽可能不想使用除此分页以外的其他功能,但如果没有其他选择,那么我别无选择,只能使用其他带有打印功能的分页功能。
当前函数
现在我要做的就是一张一张打印出来。 我需要点击第 1 页点击打印点击第 2 页点击打印等等...
目标函数
有一个按钮,让用户可以一次单击打印所有分页页面。
可能的方法
在按钮上单击具有事件类的查找按钮(在分页页面中)单击打印按钮(在代码中)然后单击下一步按钮(在代码中)然后单击打印(在代码中)等等直到最后一页。 还在研究这个
问题
更新
我不想将所有页面打印成一个页面。我想要的是按原样打印页面。表示每个页面与其他页面分开。 我希望我说得有道理
最佳答案
编辑: 我不再推荐 iFrame 方法。有更好的选择,例如打印新窗口或在打印时隐藏/显示页面的某些部分。
您可以做的是将表格添加到 iframe,然后仅打印该 iframe。
JSFiddle因为 SO 代码片段不允许我打印 iframe。
在 fiddle 中,我向名为“print_frame”的正文添加了一个隐藏的 iframe,然后添加了一个 <style>
。标记它和 #geonames
表。
function printpage() {
// display the hidden table rows
var style = "<style>.geoname {display: table-row !important; }</style>";
window.frames["print_frame"].document.body.innerHTML = style + $("#geonames")[0].outerHTML;
window.frames["print_frame"].window.focus();
window.frames["print_frame"].window.print();
}
如果您想在 iframe 中使用样式表,请注意存在跨域问题。
更新
要将内容分成多个页面,您需要使用 page-break CSS 属性。
不幸的是,这不适用于 <tr>
没有 display: block
.因此,在生成表格行的函数中,我添加了这段代码,它添加了一个我们将中断的隐藏行,并为每个新页面制作了一个标题行的副本。
if ((i + 1) % perPage === 0) {
$("#geonames").append("<tr class='pagebreak'></tr>")
$("#geonames").append($("#headerRow").clone().addClass("headerCopy"));
}
断行的 CSS
.pagebreak { display: block; page-break-after: always; }
但是,由于表格现在向下延伸到整个页面,您会在整个页面下方看到表格的边框。 Image (太高了,不能在这里显示)
更新 2
经过 OP 的更多测试后,发现在表格行上打破页面会产生一些奇怪的结果,页面顶部会出现额外的空白。
解决方法是为每个页面创建一个新表格,然后在表格上打断。
关于javascript - 打印分页表(flaviusmatis 的 simplePagination.js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36368494/
我有一台 MySQL 服务器和一台 PostgreSQL 服务器。 需要从多个表中复制或重新插入一组数据 MySQL 流式传输/同步到 PostgreSQL 表。 这种复制可以基于时间(Sync)或事
如果两个表的 id 彼此相等,我尝试从一个表中获取数据。这是我使用的代码: SELECT id_to , email_to , name_to , status_to
我有一个 Excel 工作表。顶行对应于列名称,而连续的行每行代表一个条目。 如何将此 Excel 工作表转换为 SQL 表? 我使用的是 SQL Server 2005。 最佳答案 这取决于您使用哪
我想合并两个 Django 模型并创建一个模型。让我们假设我有第一个表表 A,其中包含一些列和数据。 Table A -------------- col1 col2 col3 col
我有两个表:table1,table2,如下所示 table1: id name 1 tamil 2 english 3 maths 4 science table2: p
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 1 年前。 Improve th
下面两个语句有什么区别? newTable = orginalTable 或 newTable.data(originalTable) 我怀疑 .data() 方法具有性能优势,因为它在标准 AX 中
我有一个表,我没有在其中显式定义主键,它并不是真正需要的功能......但是一位同事建议我添加一个列作为唯一主键以随着数据库的增长提高性能...... 谁能解释一下这是如何提高性能的? 没有使用索引(
如何将表“产品”中的产品记录与其不同表“图像”中的图像相关联? 我正在对产品 ID 使用自动增量。 我觉得不可能进行关联,因为产品 ID 是自动递增的,因此在插入期间不可用! 如何插入新产品,获取产品
我有一个 sql 表,其中包含关键字和出现次数,如下所示(尽管出现次数并不重要): ____________ dog | 3 | ____________ rat | 7 | ____
是否可以使用目标表中的LAST_INSERT_ID更新源表? INSERT INTO `target` SELECT `a`, `b` FROM `source` 目标表有一个自动增量键id,我想将其
我正在重建一个搜索查询,因为它在“我看到的”中变得多余,我想知道什么 (albums_artists, artists) ( ) does in join? is it for boosting pe
以下是我使用 mysqldump 备份数据库的开关: /usr/bin/mysqldump -u **** --password=**** --single-transaction --databas
我试图获取 MySQL 表中的所有行并将它们放入 HTML 表中: Exam ID Status Assigned Examiner
如何查询名为 photos 的表中的所有记录,并知道当前用户使用单个查询将哪些结果照片添加为书签? 这是我的表格: -- -- Table structure for table `photos` -
我的网站都在 InnoDB 表上运行,目前为止运行良好。现在我想知道在我的网站上实时发生了什么,所以我将每个页面浏览量(页面、引荐来源网址、IP、主机名等)存储在 InnoDB 表中。每秒大约有 10
我在想我会为 mysql 准备两个表。一个用于存储登录信息,另一个用于存储送货地址。这是传统方式还是所有内容都存储在一张表中? 对于两个表...有没有办法自动将表 A 的列复制到表 B,以便我可以引用
我不是程序员,我从这个表格中阅读了很多关于如何解决我的问题的内容,但我的搜索效果不好 我有两张 table 表 1:成员 id*| name | surname -------------------
我知道如何在 ASP.NET 中显示真实表,例如 public ActionResult Index() { var s = db.StaffInfoDBSet.ToList(); r
我正在尝试运行以下查询: "insert into visits set source = 'http://google.com' and country = 'en' and ref = '1234
我是一名优秀的程序员,十分优秀!