mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-03 14:32:21 +02:00
4481fbe361
branch: master
SHA: c7d6de72f7
range SHA: 81f31a3106fb...c7d6de72f785
build id: 375208741
build number: 1103
638 lines
35 KiB
HTML
638 lines
35 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<base data-ice="baseUrl" href="../../../">
|
|
<title data-ice="title">src/modules/gridLayout.js | tablefilter</title>
|
|
<link type="text/css" rel="stylesheet" href="css/style.css">
|
|
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
|
|
<script src="script/prettify/prettify.js"></script>
|
|
<script src="script/manual.js"></script>
|
|
<meta name="description" content="A Javascript library making HTML tables filterable and a bit more"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="tablefilter"><meta property="twitter:description" content="A Javascript library making HTML tables filterable and a bit more"></head>
|
|
<body class="layout-container" data-ice="rootContainer">
|
|
|
|
<header>
|
|
<a href="./">Home</a>
|
|
|
|
<a href="identifiers.html">Reference</a>
|
|
<a href="source.html">Source</a>
|
|
|
|
<div class="search-box">
|
|
<span>
|
|
<img src="./image/search.png">
|
|
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
|
|
</span>
|
|
<ul class="search-result"></ul>
|
|
</div>
|
|
<a style="position:relative; top:3px;" href="https://github.com/koalyptus/TableFilter.git"><img width="20px" src="./image/github.png"></a></header>
|
|
|
|
<nav class="navigation" data-ice="nav"><div>
|
|
<ul>
|
|
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/emitter.js~Emitter.html">Emitter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/feature.js~Feature.html">Feature</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/tablefilter.js~TableFilter.html">TableFilter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-has">has</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-addClass">addClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createCheckItem">createCheckItem</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createElm">createElm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createOpt">createOpt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-createText">createText</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-elm">elm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getFirstTextNode">getFirstTextNode</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-getText">getText</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasClass">hasClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeClass">removeClass</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeElm">removeElm</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-tag">tag</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-addEvt">addEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-cancelEvt">cancelEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isKeyPressed">isKeyPressed</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-keyCode">keyCode</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-removeEvt">removeEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-stopEvt">stopEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-targetEvt">targetEvt</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-parse">parse</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsArr">defaultsArr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsBool">defaultsBool</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsFn">defaultsFn</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsNb">defaultsNb</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-defaultsStr">defaultsStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-dateSortAsc">dateSortAsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-dateSortDesc">dateSortDesc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-ignoreCase">ignoreCase</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-numSortAsc">numSortAsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-numSortDesc">numSortDesc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-sortDateStr">sortDateStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-sortNumberStr">sortNumberStr</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-contains">contains</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isEmpty">isEmpty</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-matchCase">matchCase</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-rgxEsc">rgxEsc</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-trim">trim</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-EMPTY_FN">EMPTY_FN</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isArray">isArray</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isBoolean">isBoolean</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isEmpty">isEmpty</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isFn">isFn</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isNull">isNull</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isNumber">isNumber</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isObj">isObj</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isString">isString</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-isUndef">isUndef</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-AUTO_FILTER_DELAY">AUTO_FILTER_DELAY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CELL_TAG">CELL_TAG</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CHECKLIST">CHECKLIST</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-DATE">DATE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-DOWN_ARROW_KEY">DOWN_ARROW_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ENTER_KEY">ENTER_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-ESC_KEY">ESC_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-FEATURES">FEATURES</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-FORMATTED_NUMBER">FORMATTED_NUMBER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-HEADER_TAG">HEADER_TAG</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-INPUT">INPUT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-IP_ADDRESS">IP_ADDRESS</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-MULTIPLE">MULTIPLE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NONE">NONE</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-NUMBER">NUMBER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-SELECT">SELECT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-STRING">STRING</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-TAB_KEY">TAB_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-UP_ARROW_KEY">UP_ARROW_KEY</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-root">root</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-advancedgrid">extensions/advancedGrid</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/advancedGrid/adapterEzEditTable.js~AdapterEzEditTable.html">AdapterEzEditTable</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-colops">extensions/colOps</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/colOps/colOps.js~ColOps.html">ColOps</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-colsvisibility">extensions/colsVisibility</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/colsVisibility/colsVisibility.js~ColsVisibility.html">ColsVisibility</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-filtersvisibility">extensions/filtersVisibility</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/filtersVisibility/filtersVisibility.js~FiltersVisibility.html">FiltersVisibility</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#extensions-sort">extensions/sort</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/extensions/sort/adapterSortabletable.js~AdapterSortableTable.html">AdapterSortableTable</a></span></span></li>
|
|
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#modules">modules</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/alternateRows.js~AlternateRows.html">AlternateRows</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/baseDropdown.js~BaseDropdown.html">BaseDropdown</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/checkList.js~CheckList.html">CheckList</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/clearButton.js~ClearButton.html">ClearButton</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/dateType.js~DateType.html">DateType</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/dropdown.js~Dropdown.html">Dropdown</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/gridLayout.js~GridLayout.html">GridLayout</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/hash.js~Hash.html">Hash</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/help.js~Help.html">Help</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/highlightKeywords.js~HighlightKeyword.html">HighlightKeyword</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/loader.js~Loader.html">Loader</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/markActiveColumns.js~MarkActiveColumns.html">MarkActiveColumns</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/noResults.js~NoResults.html">NoResults</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/paging.js~Paging.html">Paging</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/popupFilter.js~PopupFilter.html">PopupFilter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/rowsCounter.js~RowsCounter.html">RowsCounter</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/state.js~State.html">State</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/statusBar.js~StatusBar.html">StatusBar</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/storage.js~Storage.html">Storage</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/modules/toolbar.js~Toolbar.html">Toolbar</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasHashChange">hasHashChange</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-hasStorage">hasStorage</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-CENTER">CENTER</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-LEFT">LEFT</a></span></span></li>
|
|
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-RIGHT">RIGHT</a></span></span></li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="content" data-ice="content"><h1 data-ice="title">src/modules/gridLayout.js</h1>
|
|
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import {Feature} from '../feature';
|
|
import {createElm, removeElm, elm, tag} from '../dom';
|
|
import {addEvt, targetEvt} from '../event';
|
|
import {contains} from '../string';
|
|
import {NONE} from '../const';
|
|
import {
|
|
defaultsBool, defaultsStr, defaultsNb, defaultsArr
|
|
} from '../settings';
|
|
|
|
/**
|
|
* Grid layout, table with fixed headers
|
|
*/
|
|
export class GridLayout extends Feature {
|
|
|
|
/**
|
|
* Creates an instance of GridLayout
|
|
* @param {TableFilter} tf TableFilter instance
|
|
*/
|
|
constructor(tf) {
|
|
super(tf, 'gridLayout');
|
|
|
|
let f = this.config.grid_layout || {};
|
|
|
|
/**
|
|
* Grid-layout container width as CSS string
|
|
* @type {String}
|
|
*/
|
|
this.width = defaultsStr(f.width, null);
|
|
|
|
/**
|
|
* Grid-layout container height as CSS string
|
|
* @type {String}
|
|
*/
|
|
this.height = defaultsStr(f.height, null);
|
|
|
|
/**
|
|
* Css class for main container element
|
|
* @type {String}
|
|
*/
|
|
this.mainContCssClass = defaultsStr(f.cont_css_class, 'grd_Cont');
|
|
|
|
/**
|
|
* Css class for body table container element
|
|
* @type {String}
|
|
*/
|
|
this.contCssClass = defaultsStr(f.tbl_cont_css_class, 'grd_tblCont');
|
|
|
|
/**
|
|
* Css class for headers table container element
|
|
* @type {String}
|
|
*/
|
|
this.headContCssClass = defaultsStr(f.tbl_head_css_class,
|
|
'grd_headTblCont');
|
|
|
|
/**
|
|
* Css class for toolbar container element (rows counter, paging etc.)
|
|
* @type {String}
|
|
*/
|
|
this.infDivCssClass = defaultsStr(f.inf_grid_css_class, 'grd_inf');
|
|
|
|
/**
|
|
* Index of the headers row, default: 0
|
|
* @type {Number}
|
|
*/
|
|
this.headRowIndex = defaultsNb(f.headers_row_index, 0);
|
|
|
|
/**
|
|
* Collection of the header row indexes to be moved into headers table
|
|
* @type {Array}
|
|
*/
|
|
this.headRows = defaultsArr(f.headers_rows, [0]);
|
|
|
|
/**
|
|
* Enable or disable column filters generation, default: true
|
|
* @type {Boolean}
|
|
*/
|
|
this.filters = defaultsBool(f.filters, true);
|
|
|
|
/**
|
|
* Enable or disable column headers, default: false
|
|
* @type {Boolean}
|
|
*/
|
|
this.noHeaders = Boolean(f.no_headers);
|
|
|
|
/**
|
|
* Grid-layout default column widht as CSS string
|
|
* @type {String}
|
|
*/
|
|
this.defaultColWidth = defaultsStr(f.default_col_width, '100px');
|
|
|
|
/**
|
|
* List of column elements
|
|
* @type {Array}
|
|
* @private
|
|
*/
|
|
this.colElms = [];
|
|
|
|
/**
|
|
* Prefix for grid-layout filter's cell ID
|
|
* @type {String}
|
|
* @private
|
|
*/
|
|
this.prfxGridFltTd = '_td_';
|
|
|
|
/**
|
|
* Prefix for grid-layout header's cell ID
|
|
* @type {String}
|
|
* @private
|
|
*/
|
|
this.prfxGridTh = 'tblHeadTh_';
|
|
|
|
/**
|
|
* Mark-up of original HTML table
|
|
* @type {String}
|
|
* @private
|
|
*/
|
|
this.sourceTblHtml = tf.dom().outerHTML;
|
|
|
|
/**
|
|
* Indicates if working table has column elements
|
|
* @type {Boolean}
|
|
* @private
|
|
*/
|
|
this.tblHasColTag = tag(tf.dom(), 'col').length > 0 ? true : false;
|
|
|
|
/**
|
|
* Main container element
|
|
* @private
|
|
*/
|
|
this.tblMainCont = null;
|
|
|
|
/**
|
|
* Table container element
|
|
* @private
|
|
*/
|
|
this.tblCont = null;
|
|
|
|
/**
|
|
* Headers' table container element
|
|
* @private
|
|
*/
|
|
this.headTblCont = null;
|
|
|
|
/**
|
|
* Headers' table element
|
|
* @private
|
|
*/
|
|
this.headTbl = null;
|
|
|
|
// filters flag at TF level
|
|
tf.fltGrid = this.filters;
|
|
}
|
|
|
|
/**
|
|
* Generates a grid with fixed headers
|
|
* TODO: reduce size of init by extracting single purposed methods
|
|
*/
|
|
init() {
|
|
let tf = this.tf;
|
|
let tbl = tf.dom();
|
|
|
|
if (this.initialized) {
|
|
return;
|
|
}
|
|
|
|
// Override relevant TableFilter properties
|
|
this.setOverrides();
|
|
|
|
// Assign default column widths
|
|
this.setDefaultColWidths();
|
|
|
|
//Main container: it will contain all the elements
|
|
this.tblMainCont = this.createContainer(
|
|
'div', this.mainContCssClass);
|
|
if (this.width) {
|
|
this.tblMainCont.style.width = this.width;
|
|
}
|
|
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
|
|
|
|
//Table container: div wrapping content table
|
|
this.tblCont = this.createContainer('div', this.contCssClass);
|
|
this.setConfigWidth(this.tblCont);
|
|
if (this.height) {
|
|
this.tblCont.style.height = this.height;
|
|
}
|
|
tbl.parentNode.insertBefore(this.tblCont, tbl);
|
|
let t = removeElm(tbl);
|
|
this.tblCont.appendChild(t);
|
|
|
|
//In case table width is expressed in %
|
|
if (tbl.style.width === '') {
|
|
let tblW = this.initialTableWidth();
|
|
tbl.style.width = (contains('%', tblW) ?
|
|
tbl.clientWidth : tblW) + 'px';
|
|
}
|
|
|
|
let d = removeElm(this.tblCont);
|
|
this.tblMainCont.appendChild(d);
|
|
|
|
//Headers table container: div wrapping headers table
|
|
this.headTblCont = this.createContainer(
|
|
'div', this.headContCssClass);
|
|
|
|
//Headers table
|
|
this.headTbl = createElm('table');
|
|
let tH = createElm('tHead');
|
|
|
|
//1st row should be headers row, ids are added if not set
|
|
//Those ids are used by the sort feature
|
|
let hRow = tbl.rows[this.headRowIndex];
|
|
let sortTriggers = this.getSortTriggerIds(hRow);
|
|
|
|
//Filters row is created
|
|
let filtersRow = this.createFiltersRow();
|
|
|
|
//Headers row are moved from content table to headers table
|
|
this.setHeadersRow(tH);
|
|
|
|
this.headTbl.appendChild(tH);
|
|
if (tf.filtersRowIndex === 0) {
|
|
tH.insertBefore(filtersRow, hRow);
|
|
} else {
|
|
tH.appendChild(filtersRow);
|
|
}
|
|
|
|
this.headTblCont.appendChild(this.headTbl);
|
|
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
|
|
|
|
//THead needs to be removed in content table for sort feature
|
|
let thead = tag(tbl, 'thead');
|
|
if (thead.length > 0) {
|
|
tbl.removeChild(thead[0]);
|
|
}
|
|
|
|
// ensure table layout is always set even if already set in css
|
|
// definitions, potentially with custom css class this could be lost
|
|
this.headTbl.style.tableLayout = 'fixed';
|
|
tbl.style.tableLayout = 'fixed';
|
|
|
|
//content table without headers needs col widths to be reset
|
|
tf.setColWidths(this.headTbl);
|
|
|
|
//Headers container width
|
|
this.headTbl.style.width = tbl.style.width;
|
|
//
|
|
|
|
//scroll synchronisation
|
|
addEvt(this.tblCont, 'scroll', (evt) => {
|
|
let elm = targetEvt(evt);
|
|
let scrollLeft = elm.scrollLeft;
|
|
this.headTblCont.scrollLeft = scrollLeft;
|
|
//New pointerX calc taking into account scrollLeft
|
|
// if(!o.isPointerXOverwritten){
|
|
// try{
|
|
// o.Evt.pointerX = function(evt){
|
|
// let e = evt || global.event;
|
|
// let bdScrollLeft = tf_StandardBody().scrollLeft +
|
|
// scrollLeft;
|
|
// return (e.pageX + scrollLeft) ||
|
|
// (e.clientX + bdScrollLeft);
|
|
// };
|
|
// o.isPointerXOverwritten = true;
|
|
// } catch(err) {
|
|
// o.isPointerXOverwritten = false;
|
|
// }
|
|
// }
|
|
});
|
|
|
|
// TODO: Trigger a custom event handled by sort extension
|
|
let sort = tf.extension('sort');
|
|
if (sort) {
|
|
sort.asyncSort = true;
|
|
sort.triggerIds = sortTriggers;
|
|
}
|
|
|
|
//Col elements are enough to keep column widths after sorting and
|
|
//filtering
|
|
this.setColumnElements();
|
|
|
|
if (tf.popupFilters) {
|
|
filtersRow.style.display = NONE;
|
|
}
|
|
|
|
/** @inherited */
|
|
this.initialized = true;
|
|
}
|
|
|
|
/**
|
|
* Overrides TableFilter instance properties to adjust to grid layout mode
|
|
* @private
|
|
*/
|
|
setOverrides() {
|
|
let tf = this.tf;
|
|
tf.refRow = 0;
|
|
tf.headersRow = 0;
|
|
tf.filtersRowIndex = 1;
|
|
}
|
|
|
|
/**
|
|
* Set grid-layout default column widths if column widths are not defined
|
|
* @private
|
|
*/
|
|
setDefaultColWidths() {
|
|
let tf = this.tf;
|
|
if (tf.colWidths.length > 0) {
|
|
return;
|
|
}
|
|
|
|
tf.eachCol((k) => {
|
|
let colW;
|
|
let cell = tf.dom().rows[tf.getHeadersRowIndex()].cells[k];
|
|
if (cell.width !== '') {
|
|
colW = cell.width;
|
|
} else if (cell.style.width !== '') {
|
|
colW = parseInt(cell.style.width, 10);
|
|
} else {
|
|
colW = this.defaultColWidth;
|
|
}
|
|
tf.colWidths[k] = colW;
|
|
});
|
|
|
|
tf.setColWidths();
|
|
}
|
|
|
|
/**
|
|
* Initial table width
|
|
* @returns {Number}
|
|
* @private
|
|
*/
|
|
initialTableWidth() {
|
|
let tbl = this.tf.dom();
|
|
let width; //initial table width
|
|
|
|
if (tbl.width !== '') {
|
|
width = tbl.width;
|
|
}
|
|
else if (tbl.style.width !== '') {
|
|
width = tbl.style.width;
|
|
} else {
|
|
width = tbl.clientWidth;
|
|
}
|
|
return parseInt(width, 10);
|
|
}
|
|
|
|
/**
|
|
* Creates container element
|
|
* @param {String} tag Tag name
|
|
* @param {String} className Css class to assign to element
|
|
* @returns {DOMElement}
|
|
* @private
|
|
*/
|
|
createContainer(tag, className) {
|
|
let element = createElm(tag);
|
|
element.className = className;
|
|
return element;
|
|
}
|
|
|
|
/**
|
|
* Creates filters row with cells
|
|
* @returns {HTMLTableRowElement}
|
|
* @private
|
|
*/
|
|
createFiltersRow() {
|
|
let tf = this.tf;
|
|
let filtersRow = createElm('tr');
|
|
if (this.filters && tf.fltGrid) {
|
|
tf.externalFltIds = [];
|
|
tf.eachCol((j) => {
|
|
let fltTdId = `${tf.prfxFlt + j + this.prfxGridFltTd + tf.id}`;
|
|
let cl = createElm(tf.fltCellTag, ['id', fltTdId]);
|
|
filtersRow.appendChild(cl);
|
|
tf.externalFltIds[j] = fltTdId;
|
|
});
|
|
}
|
|
return filtersRow;
|
|
}
|
|
|
|
/**
|
|
* Generates column elements if necessary and assigns their widths
|
|
* @private
|
|
*/
|
|
setColumnElements() {
|
|
let tf = this.tf;
|
|
let cols = tag(tf.dom(), 'col');
|
|
this.tblHasColTag = cols.length > 0;
|
|
|
|
for (let k = (tf.getCellsNb() - 1); k >= 0; k--) {
|
|
let col;
|
|
|
|
if (!this.tblHasColTag) {
|
|
col = createElm('col');
|
|
tf.dom().insertBefore(col, tf.dom().firstChild);
|
|
} else {
|
|
col = cols[k];
|
|
}
|
|
col.style.width = tf.colWidths[k];
|
|
this.colElms[k] = col;
|
|
}
|
|
this.tblHasColTag = true;
|
|
}
|
|
|
|
/**
|
|
* Sets headers row in headers table
|
|
* @param {HTMLHeadElement} tableHead Table head element
|
|
* @private
|
|
*/
|
|
setHeadersRow(tableHead) {
|
|
if (this.noHeaders) {
|
|
// Handle table with no headers, assuming here headers do not
|
|
// exist
|
|
tableHead.appendChild(createElm('tr'));
|
|
} else {
|
|
// Headers row are moved from content table to headers table
|
|
for (let i = 0; i < this.headRows.length; i++) {
|
|
let row = this.tf.dom().rows[this.headRows[i]];
|
|
tableHead.appendChild(row);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets width defined in configuration to passed element
|
|
* @param {DOMElement} element DOM element
|
|
* @private
|
|
*/
|
|
setConfigWidth(element) {
|
|
if (!this.width) {
|
|
return;
|
|
}
|
|
if (this.width.indexOf('%') !== -1) {
|
|
element.style.width = '100%';
|
|
} else {
|
|
element.style.width = this.width;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns a list of header IDs used for specifing external sort triggers
|
|
* @param {HTMLTableRowElement} row DOM row element
|
|
* @returns {Array} List of IDs
|
|
* @private
|
|
*/
|
|
getSortTriggerIds(row) {
|
|
let tf = this.tf;
|
|
let sortTriggers = [];
|
|
tf.eachCol((n) => {
|
|
let c = row.cells[n];
|
|
let thId = c.getAttribute('id');
|
|
if (!thId || thId === '') {
|
|
thId = `${this.prfxGridTh + n}_${tf.id}`;
|
|
c.setAttribute('id', thId);
|
|
}
|
|
sortTriggers.push(thId);
|
|
});
|
|
return sortTriggers;
|
|
}
|
|
|
|
/**
|
|
* Removes the grid layout
|
|
*/
|
|
destroy() {
|
|
let tf = this.tf;
|
|
let tbl = tf.dom();
|
|
|
|
if (!this.initialized) {
|
|
return;
|
|
}
|
|
let t = removeElm(tbl);
|
|
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
|
|
removeElm(this.tblMainCont);
|
|
|
|
this.tblMainCont = null;
|
|
this.headTblCont = null;
|
|
this.headTbl = null;
|
|
this.tblCont = null;
|
|
|
|
tbl.outerHTML = this.sourceTblHtml;
|
|
//needed to keep reference of table element for future usage
|
|
this.tf.tbl = elm(tf.id);
|
|
|
|
this.initialized = false;
|
|
}
|
|
}
|
|
</code></pre>
|
|
|
|
</div>
|
|
|
|
<footer class="footer">
|
|
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
|
|
</footer>
|
|
|
|
<script src="script/search_index.js"></script>
|
|
<script src="script/search.js"></script>
|
|
<script src="script/pretty-print.js"></script>
|
|
<script src="script/inherited-summary.js"></script>
|
|
<script src="script/test-summary.js"></script>
|
|
<script src="script/inner-link.js"></script>
|
|
<script src="script/patch-for-local.js"></script>
|
|
</body>
|
|
</html>
|