forked from swimlane/ngx-datatable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
434 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'chkbox-selection-demo', | ||
template: ` | ||
<div> | ||
<h3> | ||
Checkbox Selection | ||
<small> | ||
<a href="#" (click)="add()">Add</a> | | ||
<a href="#" (click)="update()">Update</a> | | ||
<a href="#" (click)="remove()">Remove</a> | ||
</small> | ||
</h3> | ||
<div style='float:left;width:75%'> | ||
<swui-datatable | ||
style="width: 90%" | ||
class="material" | ||
[rows]="rows" | ||
[columnMode]="'force'" | ||
[headerHeight]="50" | ||
[footerHeight]="50" | ||
[rowHeight]="'auto'" | ||
[limit]="5" | ||
[selected]="selected" | ||
[selectionType]="'checkbox'" | ||
(activate)="onActivate($event)" | ||
(select)='onSelect($event)'> | ||
<swui-datatable-column | ||
[width]="30" | ||
[sortable]="false" | ||
[canAutoResize]="false" | ||
[draggable]="false" | ||
[resizeable]="false" | ||
[headerCheckboxable]="true" | ||
[checkboxable]="true"> | ||
</swui-datatable-column> | ||
<swui-datatable-column name="Name"></swui-datatable-column> | ||
<swui-datatable-column name="Gender"></swui-datatable-column> | ||
<swui-datatable-column name="Company"></swui-datatable-column> | ||
</swui-datatable> | ||
</div> | ||
<div class='selected-column'> | ||
<h4>Selections <small>({{selected?.length}})</small></h4> | ||
<ul> | ||
<li *ngFor='let sel of selected'> | ||
{{sel.name}} | ||
</li> | ||
<li *ngIf="!selected?.length">No Selections</li> | ||
</ul> | ||
</div> | ||
</div> | ||
` | ||
}) | ||
export class CheckboxSelectionComponent { | ||
|
||
rows = []; | ||
selected = []; | ||
|
||
constructor() { | ||
this.fetch((data) => { | ||
this.rows = data; | ||
}); | ||
} | ||
|
||
fetch(cb) { | ||
const req = new XMLHttpRequest(); | ||
req.open('GET', `assets/data/company.json`); | ||
|
||
req.onload = () => { | ||
cb(JSON.parse(req.response)); | ||
}; | ||
|
||
req.send(); | ||
} | ||
|
||
onSelect({ selected }) { | ||
console.log('Select Event', selected, this.selected); | ||
|
||
this.selected.splice(0, this.selected.length); | ||
this.selected.push(...selected); | ||
} | ||
|
||
onActivate(event) { | ||
console.log('Activate Event', event); | ||
} | ||
|
||
add() { | ||
this.selected.push(this.rows[1], this.rows[3]); | ||
} | ||
|
||
update() { | ||
this.selected = [ this.rows[1], this.rows[3] ]; | ||
} | ||
|
||
remove() { | ||
this.selected = []; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,50 @@ | ||
# Table Column Options | ||
|
||
### `name` | ||
### `name`: `string` | ||
Column label. If none specified, it will use the prop value and decamelize it. | ||
|
||
### `prop` | ||
### `prop`: `string` | ||
The property to bind the row values to. If `undefined`, it will camelcase the name value. | ||
|
||
### `flexGrow` | ||
### `flexGrow`: `number` | ||
The grow factor relative to other columns. Same as the [flex-grow API](http =//www.w3.org/TR/css3-flexbox/). | ||
It will any available extra width and distribute it proportionally according to all columns' flexGrow values. Default value: `0` | ||
|
||
### `minWidth` | ||
### `minWidth`: `number` | ||
Minimum width of the column in pixels. Default value: `100` | ||
|
||
### `maxWidth` | ||
### `maxWidth`: `number` | ||
Maximum width of the column in pixels. Default value: `undefined` | ||
|
||
### `width` | ||
### `width`: `number` | ||
The width of the column by default in pixels. Default value: `150` | ||
|
||
### `resizeable` | ||
### `resizeable`: `boolean` | ||
The column can be resized manually by the user. Default value: `true` | ||
|
||
### `comparator` | ||
Custom sort comparator, used to apply custom sorting via client-side. See | ||
[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) for more info. | ||
|
||
### `sortable` | ||
### `sortable`: `boolean` | ||
Sorting of the row values by this column. Default value: `true` | ||
|
||
### `draggable` | ||
### `draggable`: `boolean` | ||
The column can be dragged to re-order. Default value: `true` | ||
|
||
### `canAutoResize` | ||
### `canAutoResize`: `boolean` | ||
Whether the column can automatically resize to fill extra space. Default value: `true` | ||
|
||
### `cellTemplate` | ||
### `cellTemplate`: `TemplateRef` | ||
Angular TemplateRef allowing you to author custom body cell templates | ||
|
||
### `headerTemplate` | ||
### `headerTemplate`: `TemplateRef` | ||
Angular TemplateRef allowing you to author custom header cell templates | ||
|
||
### `checkboxable`: `boolean` | ||
Indicates whether the column should show a checkbox component for selection. Only | ||
applicable when the selection mode is `checkbox`. | ||
|
||
### `headerCheckboxable`: `boolean` | ||
Indicates whether the column should show a checkbox component in the header cell. | ||
Only applicable when the selection mode is `checkbox`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.