diff --git a/README.md b/README.md index 3d8167d..d036d31 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,7 @@ See live demos [here]( http://jonshaffer.github.io/angular-data-table/). or Github download or clone of course! -#### Run Demos - -Ensure you have the latest NPM and JSPM installed globally. If you don't already have JSPM installed run: `npm install jspm -g`. - -- `npm install` -- `jspm install` -- `gulp watch serve` -- Open your browser to `http://localhost:9000` - -docs coming soon, in the meantime, 'View Source' is your friend ;)! -#### Build - -`gulp release` to build Modules, ES* via Babel and compile. #### Include @@ -68,13 +55,19 @@ There is also the CSS too: - `./release/dataTable.css` - The base CSS, pretty much required - `./release/material.css` - Material theme +- `./release/icons.css` - If you want to show fancy icons when sorting #### Usage -Include the module in your angular app module like: +Include the `data-table` module as a dependency: + +```javascript + var module = angular.module('myApp', [ 'data-table' ]); +``` - var myApp = angular.module('myApp', [ 'data-table' ]); +Set the data and the options in your controller: +```javascript module.controller('HomeController', function($scope){ $scope.options = { scrollbarV: false @@ -85,18 +78,83 @@ Include the module in your angular app module like: { name: 'Marjan', gender: 'Male' } ]; }); +``` then using expressive markup in your template: +```html {{$row.name}}: {{$cell}} +``` and your off to the races! See live demos [here](http://jonshaffer.github.io/angular-data-table/). +## API + +The data table can be created with the following `options`: + +- `checkboxSelection`: Checkbox selection vs row click (default: `false`) +- `columnMode`: Possible values are `flex`, `force` and `standard` (default: `standard`) +- `columns` + - `canAutoResize`: Whether the column can automatically resize to fill space in the table (default: `true`) + - `cellDataGetter`: Type `function`. Returns content for the `cellRenderer`. If not provided, the cell data will be collected from row data instead (default: `undefined`) + - `cellRenderer`: Type `function`. Returns HTML for the cell. + - `className`: CSS class for the body cell (default: `undefined`) + - `comparator`: Type `function`. Custom sort comparator, pass `false` if you want to do server sort + - `flexGrow`: The growth factor relative to other columns (default: `0`) + - `frozenLeft`: Column is pinned to the left (default: `false`) + - `frozenRight`: Column is pinned to the right (default: `false`) + - `group`: Whether to group by the column (default: `false`) + - `headerCheckbox`: Toggles the checkbox column in the header for selecting all values given to the grid (default: `false`) + - `headerClassName`: CSS class for the header cell (default: `undefined`) + - `headerRenderer`: Type `function`. Returns HTML for the cell (default: `undefined`) + - `isCheckboxColumn`: Adds the checkbox selection to the column (default: `false`) + - `isTreeColumn`: Adds +/- button and makes a secondary call to load nested data (default: `false`) + - `maxWidth`: Maximum width, in pixels (default: `undefined`) + - `minWidth`: Minimum width, in pixels (default: `100`) + - `name`: Name of the column + - `prop`: Property to use to get the data + - `resizable`: Whether the column can be resized (default: `true`) + - `sort`: Default sort asecending/descending for the column (default: `undefined`) + - `sortBy`: Property by which to sort (default: `undefined`) + - `sortable`: Whether the column can be sorted (default: `true`) + - `template` + - `width`: Width, in pixels (default: `150`) +- `emptyMessage`: Message to show when array is presented but contains no values (default: `'No data to display'`) +- `footerHeight`: Footer height in pixels. Pass a `falsey` value for no footer (default: `0`) +- `headerHeight`: Header height in pixels. Pass a `falsey` value for no header (default: `30`) +- `loadingMessage`: Loading message presented when the array is undefined (default: `'Loading...'`) +- `multiSelect`: Whether users can select multiple items (default: `false`) +- `paging` + - `externalPaging`. Default `false` + - `size`. Default `undefined` + - `count`. Default `0` + - `offset`. Default `0` + - `loadingIndicator`. Default `false` +- `reorderable`: Whether you can reorder columns (default: `true`) +- `rowHeight`: Row height in pixels, necessary if using lazy rendering (default: `30`) +- `scrollbarV`: Enable vertical scrollbars (default: `true`) +- `selectable`: Whether users can select items (default: `false`) + +## Contributing + +#### Run Demos + +Ensure you have the latest NPM and JSPM installed globally. If you don't already have JSPM installed run: `npm install jspm -g`. + +- `npm install` +- `jspm install` +- `gulp watch serve` +- Open your browser to `http://localhost:9000` + +#### Build + +`gulp release` to build Modules, ES* via Babel and compile. + ## Credits `angular-data-table` is a [Swimlane](http://swimlane.com) open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations. diff --git a/release/icons.css b/release/icons.css new file mode 100644 index 0000000..5c5d101 --- /dev/null +++ b/release/icons.css @@ -0,0 +1,88 @@ +@charset "UTF-8"; + +/* data-table */ +@font-face { + font-family: "data-table"; + src:url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.eot"); + src:url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.eot?#iefix") format("embedded-opentype"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.woff") format("woff"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.ttf") format("truetype"), + url("https://file.myfontastic.com/Jnf54BZCm7mSjGCxNRbfp3/fonts/1447204703.svg#1447204703") format("svg"); + font-weight: normal; + font-style: normal; +} + +[data-icon]:before { + font-family: "data-table" !important; + content: attr(data-icon); + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +[class^="icon-"]:before, +[class*=" icon-"]:before { + font-family: "data-table" !important; + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-filter:before { + content: "b"; +} +.icon-collapse:before { + content: "a"; +} +.icon-expand:before { + content: "c"; +} +.icon-close:before { + content: "d"; +} +.icon-up:before { + content: "e"; +} +.icon-down:before { + content: "f"; +} +.icon-sort:before { + content: "g"; +} +.icon-done:before { + content: "h"; +} +.icon-done-all:before { + content: "i"; +} +.icon-search:before { + content: "j"; +} +.icon-pin:before { + content: "k"; +} +.icon-add:before { + content: "m"; +} +.icon-left:before { + content: "o"; +} +.icon-right:before { + content: "p"; +} +.icon-skip:before { + content: "q"; +} +.icon-prev:before { + content: "r"; +}