- Notifications
You must be signed in to change notification settings - Fork19
Make your HTML tables look great on every device
License
awerlang/angular-responsive-tables
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Make your HTML tables look great on every device.Compatible withAngularJS 1.3.4+.
Currently, browsers for mobile devices like smartphones doesn't do anything to have a proper presentation of tables,and then scrollbars will show up and ruin your design.
In the search of a solution to this problem I have found many different approaches. Some of themstill rely on horizontal scrollbars. While I believe this layout could be useful for some use cases,I felt that a default solution should avoid horizontal scrollbars entirely. Then I came up with thishighly reusable directive.
All this work is based on the following assumptions:
- If it isflexible, then it would solve most problems, even ones not aimed by the library author's;
- Focusing on the task ofadding responsiveness, in order to accomplish a greater objective (easy to use tabular data);
- Do work with astandard HTML table, not requiring any extraneous markup;
- Donot change default tabular layout unless a smaller display is detected;
- Provideconvenience without sacrificing flexibility;
- By keepingcode base simple, it is easier to reason about and evolve;
- By fully covering with tests, it canevolve without introducing bugs.
- Angular native implementation compatible with 1.3.4+;
- Keep things DRY;
- Supports static and dynamic (ng-repeat) rows;
- Supports conditionally shown (ng-if) columns;
- Supports dynamic headers (ng-repeat);
- Supports nested tables (responsive or not in their own right);
- Easy to apply any style on top of it;
- Works with any base CSS framework;
- Should integrate seamlessly with any table component you might choose to use.
- Choose what columns to show/hide according to a given screen resolution;
- Choose when it would be best to hide columns or collapse all columns;
- Define a header and/or custom template for collapsed columns/row;
- Allow collapse/expand column details.
<table wt-responsive-table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr></table>- table: wt-responsive-table
- td: responsive-omit-title: title should be ommited
- td: responsive-omit-if-empty: no row for empty cells
- td: data-title: use to override the header for a given row/cell
npm install --save angular-responsive-tablesbower install angular-responsive-tables --save<link rel="stylesheet" href="release/angular-responsive-tables.min.css"><script type="text/javascript" src="release/angular-responsive-tables.min.js"></script>var app = angular.module('app', ['wt.responsive']);It's possible to override a header with adata-title attribute:
<tr> <td data-title="column 1">tom</td> <td data-title="column 2">jerry</td></tr>This is by design. To avoid expensive digest cycles only the content from the first digest cycle is used.There are no watchers being setup.
When loading column names with an asynchronous task, that is, column names are not available when first compiling the table element, rows in responsive mode won't have headers even after the task completes.
To avoid this problem, use anng-if to conditionally present the element on screen.
<table wt-responsive-table ng-if="columnNames && columnNames.length">Because IE9 doesn't handle correctly adisplay CSS rule for<td>, if you need to support it, you can use the following style, only for IE9:
<!--[ifIE 9]><style>/* rules for IE9 only */.responsive { overflow: hidden;}.responsivetd:nth-child(odd), .responsivetd:nth-child(even) { float: left; width: 100%;}</style><![endif]-->
CSS based on original work by Chris Coyier (http://css-tricks.com/responsive-data-tables/). In this article, he covers approaches to responsive tables. I modified it to work around CSS specificity and to keep things DRY.
MIT
About
Make your HTML tables look great on every device
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.