Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
column-resizer
Advanced tools
ColumnResizer is a fork of the jQuery plugin colResizable. The plugin is rewritten as vanilla ES6 javascript.
Column-resizer can be used directly as a script in a page:
<head>
<script src="js/column-resizer.js"></script>
<script type="text/javascript">
window.onload = function() {
let resizable = ColumnResizer.default;
new resizable(document.querySelector("#somethingUnique"),{
liveDrag:true,
draggingClass:"rangeDrag",
gripInnerHtml:"<div class='rangeGrip'></div>",
minWidth:8
});
};
</script>
</head>
<body>
<table id="somethingUnique" width="100%" >
<tr> <th> header </th> <th> header </th> </tr>
<tr> <td> cell </td> <td> cell </td> </tr>
<tr> <td> cell </td> <td> cell </td> </tr>
</table>
</body>
It can also be used as an ES6 module as in this React example:
import ColumnResizer from 'column-resizer';
import React, { Component } from 'react';
class MyTable extends Component {
/** Other implementation ignored ... **/
componentDidMount() {
if (this.props.resizable) {
this.enableResize();
}
}
componentWillUnmount() {
if (this.props.resizable) {
this.disableResize();
}
}
componentDidUpdate() {
if (this.props.resizable) {
this.enableResize();
}
}
componentWillUpdate() {
if (this.props.resizable) {
this.disableResize();
}
}
enableResize() {
const normalRemote = ReactDOM.findDOMNode(this)
.querySelector(`#${this.bodyId}`);
const options = this.props.resizerOptions;
options.remoteTable = normalRemote;
if (!this.resizer) {
this.resizer = new ColumnResizer(
ReactDOM.findDOMNode(this)
.querySelector(`#${this.headerId}`), options);
} else {
this.resizer.reset(options);
}
}
disableResize() {
if (this.resizer) {
// This will return the current state of the
// options including column widths.
// These widths can be saved so the table
// can be initialized with them.
this.resizer.reset({ disable: true });
}
}
}
resizeMode: [type: string] [default: 'fit'] [values: 'fit', 'flex', 'overflow']
It is used to set how the resize method works. Those are the possible values:
'fit'
: this is default resizing model, in which resizing a column does not alter table width, which means that when a column is expanded the next one shrinks.'flex'
: table can change its width and each column can shrink or expand independently if there is enough space in the parent container. If there is not enough space, columns will share its width as they are resized. Table will never get bigger than its parent.'overflow'
: allows resize of columns with overflow of parent container.When set to true it aims to remove all previously added enhancements such as events and additional DOM elements assigned by this plugin to a single or collection of tables. It is required to disable a previously resized table prior its removal from the document object tree using JavaScript, and also before any DOM manipulations to an already resized table such as adding columns, rows, etc.
An array of column indexes to be excluded, so it will not be possible to drag them manually.
When set to true the table layout is updated while dragging column anchors. liveDrag enabled is more CPU consuming so it is not recommended for slow computers, specially when dealing with huge or extremely complicated tables.
This attribute should be set to true if the table is inside of an updatePanel or any other kind of partial page refresh using ajax. Table's ID should be same before and after the partial partial refresh.
Its purpose is to allow column anchor customization by defining the HTML to be used in the column grips to provide some visual feedback. It can be used in a wide range of ways to obtain very different outputs, and its flexibility can be increased by combining it with the draggingClass attribute.
This attribute is used as the css class assigned to column anchors while being dragged. It can be used for visual feedback purposes.
This value specifies the minimum width (measured in pixels) that is allowed for the columns.
This attribute can be used to prevent vertical expansion of the column anchors to fit the table height. If it is set to true, column handler's size will be bounded to the first row's vertical size.
This attribute can be used to customize the cursor that will be displayed when the user is positioned on the column anchors.
Defines the cursor that will be used while the user is resizing a column.
Flush is only effective when postbackSafe is enabled. Its purpose is to remove all previously stored data related to the current table layout to get it back to its original layout preventing width restoration after postback.
If the target table contains an explicit margin-left CSS rule, the same value must be used in this attribute (for example: "auto", "20%", "10px"). The reason why it is needed it is because most browsers (all except of IE) don’t allow direct access to the current CSS rule applied to an element in its original units (such as "%", "em" or "auto" values).
It behaves in exactly the same way than the previous attribute but applied to the right margin.
Table element whose column widths will be set by the current table. Remote table must have the same number of columns.
An array of column widths to set the initial width.
If a callback function is supplied it will be fired when the user has ended dragging a column anchor altering the previous table layout. The callback function can obtain a reference to the updated table through the currentTarget attribute of the event retrieved by parameters
This event is fired while dragging a column anchor if liveDrag is enabled. It can be useful if the table is being used as a multiple range slider. The callback function can obtain a reference to the updated table through the currentTarget attribute of the event retrieved by parameters
FAQs
Javascript to resize table columns
The npm package column-resizer receives a total of 8,208 weekly downloads. As such, column-resizer popularity was classified as popular.
We found that column-resizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.