This time I will share jQuery Plugin and tutorial about Align Decimals In A Data Table – align-column, hope it will help you in programming stack.
align-column is a jQuery table formatting plugin to align and center decimals by any character or decimal point in table cells for better readability & data comparison.
Intended for Scientific Table and Statistics Table to help users quickly find out the difference in tabular data in the same column between different rows.
How to use it:
1. Insert the JavaScript file jquery.align-column.js
after jQuery.
1 |
< script src = "/path/to/cdn/jquery.min.js" ></ script > |
2 |
< script src = "/path/to/jquery.align-column.js" ></ script > |
2. Call the function alignColumn
on your HTML table and define the column index in which you want to align & center decimals.
02 |
< caption >Aligned HTML</ caption > |
2 |
$( 'table' ).alignColumn(0); |
5 |
$( 'table' ).alignColumn([0, 1, 2, 3]); |
3. Center the tabular data by any character you specify.
01 |
$( 'table' ).alignColumn(1, { |
02 |
center: ':' , debug: true |
05 |
$( 'table' ).alignColumn(2, { |
09 |
$( 'table' ).alignColumn(3, { |
13 |
$( 'table' ).alignColumn(4, { |
4. Enable the debug mode if needed.
1 |
$( 'table' ).alignColumn(4, { |
5. Determine whether to ignore table headers. Default: true.
1 |
$( 'table' ).alignColumn(4, { |
6. Add a CSS class to table cells after aligned. Default: ‘added’.
1 |
$( 'table' ).alignColumn(4, { |
3 |
addedCellClass: 'custom' |
This awesome jQuery plugin is developed by ndp-software. For more Advanced Usages, please check the demo page or visit the official website.