Skip to content

Commit f3aa8b2

Browse files
committed
优化子元素TD选择器
优化固定列高度计算
1 parent 57df514 commit f3aa8b2

File tree

7 files changed

+40
-33
lines changed

7 files changed

+40
-33
lines changed

dist/bootstrap-table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@
19371937
for (var key in events) {
19381938
that.$body.find('>tr:not(.no-records-found)').each(function () {
19391939
var $tr = $(this),
1940-
$td = $tr.find(that.options.cardView ? '.card-view' : 'td').eq(fieldIndex),
1940+
$td = $tr.find(that.options.cardView ? '.card-view' : '>td').eq(fieldIndex),
19411941
index = key.indexOf(' '),
19421942
name = key.substring(0, index),
19431943
el = key.substring(index + 1),

dist/bootstrap-table.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/extensions/fixed-columns/bootstrap-table-fixed-columns.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,21 @@
287287
var $fixedBody = $fixedColumns.find('.fixed-table-body');
288288

289289
var tableBody = that.$tableBody.get(0);
290-
var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
291-
var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
292-
if (typeof that.options.height !== 'undefined') paginationHeight = 0;
293-
var height = that.$tableContainer.outerHeight(true) - scrollHeight - paginationHeight + 1;
294-
$fixedColumns.css({
295-
height: height,
296-
"min-height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
297-
});
298-
$fixedBody.css({
299-
height: height - $fixedHeader.height(),
300-
"min-height": "calc(100% - " + $fixedHeader.height() + "px)",
301-
overflow: "hidden"
302-
});
290+
291+
var resizeHeight = function (){
292+
var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
293+
var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
294+
if (typeof that.options.height !== 'undefined') paginationHeight = 0;
295+
$fixedColumns.css({
296+
"height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
297+
});
298+
$fixedBody.css({
299+
"height": "calc(100% - " + $fixedHeader.height() + "px)",
300+
overflow: "hidden"
301+
});
302+
};
303+
$(window).on("resize", resizeHeight);
304+
resizeHeight();
303305

304306
return $fixedBody;
305307
};

dist/extensions/fixed-columns/bootstrap-table-fixed-columns.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "fastadmin-bootstraptable",
33
"description": "An extended Bootstrap table with radio, checkbox, sort, pagination, and other added features. (supports twitter bootstrap v2 and v3).",
4-
"version": "1.11.9",
4+
"version": "1.11.10",
55
"main": "./dist/bootstrap-table.js",
66
"devDependencies": {
77
"cz-conventional-changelog": "^1.1.5",
@@ -36,5 +36,8 @@
3636
"commitizen": {
3737
"path": "./node_modules/cz-conventional-changelog"
3838
}
39+
},
40+
"dependencies": {
41+
"uglify-js": "^2.8.29"
3942
}
4043
}

src/bootstrap-table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@
19371937
for (var key in events) {
19381938
that.$body.find('>tr:not(.no-records-found)').each(function () {
19391939
var $tr = $(this),
1940-
$td = $tr.find(that.options.cardView ? '.card-view' : 'td').eq(fieldIndex),
1940+
$td = $tr.find(that.options.cardView ? '.card-view' : '>td').eq(fieldIndex),
19411941
index = key.indexOf(' '),
19421942
name = key.substring(0, index),
19431943
el = key.substring(index + 1),

src/extensions/fixed-columns/bootstrap-table-fixed-columns.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,21 @@
287287
var $fixedBody = $fixedColumns.find('.fixed-table-body');
288288

289289
var tableBody = that.$tableBody.get(0);
290-
var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
291-
var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
292-
if (typeof that.options.height !== 'undefined') paginationHeight = 0;
293-
var height = that.$tableContainer.outerHeight(true) - scrollHeight - paginationHeight + 1;
294-
$fixedColumns.css({
295-
height: height,
296-
"min-height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
297-
});
298-
$fixedBody.css({
299-
height: height - $fixedHeader.height(),
300-
"min-height": "calc(100% - " + $fixedHeader.height() + "px)",
301-
overflow: "hidden"
302-
});
290+
291+
var resizeHeight = function (){
292+
var scrollHeight = tableBody.scrollWidth > tableBody.clientWidth ? getScrollBarWidth() : 0;
293+
var paginationHeight = $(".fixed-table-pagination", that.$tableContainer).height();
294+
if (typeof that.options.height !== 'undefined') paginationHeight = 0;
295+
$fixedColumns.css({
296+
"height": "calc(100% - " + (paginationHeight + scrollHeight) + "px)"
297+
});
298+
$fixedBody.css({
299+
"height": "calc(100% - " + $fixedHeader.height() + "px)",
300+
overflow: "hidden"
301+
});
302+
};
303+
$(window).on("resize", resizeHeight);
304+
resizeHeight();
303305

304306
return $fixedBody;
305307
};

0 commit comments

Comments
 (0)