mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-08 08:52:32 +02:00
Merge pull request #583 from koalyptus/auto-min-width
introduce default column width
This commit is contained in:
commit
b6d9bddc6f
|
@ -13,7 +13,7 @@
|
|||
"array-bracket-spacing": 2,
|
||||
"keyword-spacing": ["error", { "after": true, "before": true }],
|
||||
"max-depth": [2, 7],
|
||||
"max-statements": [2, 130],
|
||||
"max-statements": [2, 131],
|
||||
"complexity": [2, 41],
|
||||
"no-unused-vars": 2,
|
||||
"no-eval": 2,
|
||||
|
|
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.6.23 - Starter</title>
|
||||
<title>tablefilter v0.6.24 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.6.23</h1>
|
||||
<h1>tablefilter v0.6.24</h1>
|
||||
|
||||
|
||||
|
||||
|
|
2
dist/tablefilter/tablefilter.js
vendored
2
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
2
dist/tablefilter/tablefilter.js.map
vendored
2
dist/tablefilter/tablefilter.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.6.23",
|
||||
"version": "0.6.24",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
|
|
@ -268,6 +268,11 @@ export class TableFilter {
|
|||
*/
|
||||
this.colWidths = defaultsArr(f.col_widths, []);
|
||||
|
||||
/**
|
||||
* Default column width when column widths are defined
|
||||
*/
|
||||
this.defaultColWidth = defaultsNb(f.default_col_width, 100);
|
||||
|
||||
/**
|
||||
* Css class for a filter element
|
||||
* @type {String}
|
||||
|
@ -2520,9 +2525,11 @@ export class TableFilter {
|
|||
let tableWidth = tbl.clientWidth;
|
||||
|
||||
if (colWidths.length > 0) {
|
||||
let defaultWidth = this.defaultColWidth;
|
||||
tableWidth = colWidths
|
||||
.reduce((x, y) =>
|
||||
parseInt((x || 0), 10) + parseInt((y || 0), 10)
|
||||
parseInt((x || defaultWidth), 10) +
|
||||
parseInt((y || defaultWidth), 10)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
deepEqual(cols[1].style.width, '100px', 'Expected column width');
|
||||
deepEqual(cols[4].style.width, '', 'Expected column width');
|
||||
deepEqual(tf.dom().style.width, '545px', 'Table width set');
|
||||
deepEqual(tf.dom().style.width, '645px', 'Table width set');
|
||||
deepEqual(tf.dom().style.tableLayout, 'fixed', 'Table layout fixed');
|
||||
});
|
||||
|
||||
|
@ -22,14 +22,14 @@
|
|||
tf = null;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_widths: ['150px', '100px', '175px', '120px', '200px'],
|
||||
col_widths: ['150px', '100px', '175px', '120px', null],
|
||||
grid_layout: true
|
||||
});
|
||||
tf.init();
|
||||
var gridLayout = tf.feature('gridLayout');
|
||||
var cols = gridLayout.headTbl.getElementsByTagName('col');
|
||||
deepEqual(cols[0].style.width, '150px', 'Expected column width');
|
||||
deepEqual(cols[4].style.width, '200px', 'Expected column width');
|
||||
deepEqual(cols[3].style.width, '120px', 'Expected column width');
|
||||
deepEqual(
|
||||
tf.dom().style.width === gridLayout.headTbl.style.width,
|
||||
true,
|
||||
|
|
Loading…
Reference in a new issue