mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-03 23:23:17 +02:00
introduce default column width
This commit is contained in:
parent
39bbe6a19a
commit
025717f61c
|
@ -13,7 +13,7 @@
|
||||||
"array-bracket-spacing": 2,
|
"array-bracket-spacing": 2,
|
||||||
"keyword-spacing": ["error", { "after": true, "before": true }],
|
"keyword-spacing": ["error", { "after": true, "before": true }],
|
||||||
"max-depth": [2, 7],
|
"max-depth": [2, 7],
|
||||||
"max-statements": [2, 130],
|
"max-statements": [2, 131],
|
||||||
"complexity": [2, 41],
|
"complexity": [2, 41],
|
||||||
"no-unused-vars": 2,
|
"no-unused-vars": 2,
|
||||||
"no-eval": 2,
|
"no-eval": 2,
|
||||||
|
|
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>tablefilter v0.6.23 - Starter</title>
|
<title>tablefilter v0.6.24 - Starter</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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",
|
"name": "tablefilter",
|
||||||
"version": "0.6.23",
|
"version": "0.6.24",
|
||||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": {
|
"author": {
|
||||||
|
|
|
@ -268,6 +268,11 @@ export class TableFilter {
|
||||||
*/
|
*/
|
||||||
this.colWidths = defaultsArr(f.col_widths, []);
|
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
|
* Css class for a filter element
|
||||||
* @type {String}
|
* @type {String}
|
||||||
|
@ -2520,9 +2525,11 @@ export class TableFilter {
|
||||||
let tableWidth = tbl.clientWidth;
|
let tableWidth = tbl.clientWidth;
|
||||||
|
|
||||||
if (colWidths.length > 0) {
|
if (colWidths.length > 0) {
|
||||||
|
let defaultWidth = this.defaultColWidth;
|
||||||
tableWidth = colWidths
|
tableWidth = colWidths
|
||||||
.reduce((x, y) =>
|
.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(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||||
deepEqual(cols[1].style.width, '100px', 'Expected column width');
|
deepEqual(cols[1].style.width, '100px', 'Expected column width');
|
||||||
deepEqual(cols[4].style.width, '', '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');
|
deepEqual(tf.dom().style.tableLayout, 'fixed', 'Table layout fixed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@
|
||||||
tf = null;
|
tf = null;
|
||||||
tf = new TableFilter('demo', {
|
tf = new TableFilter('demo', {
|
||||||
base_path: '../dist/tablefilter/',
|
base_path: '../dist/tablefilter/',
|
||||||
col_widths: ['150px', '100px', '175px', '120px', '200px'],
|
col_widths: ['150px', '100px', '175px', '120px', null],
|
||||||
grid_layout: true
|
grid_layout: true
|
||||||
});
|
});
|
||||||
tf.init();
|
tf.init();
|
||||||
var gridLayout = tf.feature('gridLayout');
|
var gridLayout = tf.feature('gridLayout');
|
||||||
var cols = gridLayout.headTbl.getElementsByTagName('col');
|
var cols = gridLayout.headTbl.getElementsByTagName('col');
|
||||||
deepEqual(cols[0].style.width, '150px', 'Expected column width');
|
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(
|
deepEqual(
|
||||||
tf.dom().style.width === gridLayout.headTbl.style.width,
|
tf.dom().style.width === gridLayout.headTbl.style.width,
|
||||||
true,
|
true,
|
||||||
|
|
Loading…
Reference in a new issue