Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/table optional classes #144

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modified code to make striped and bordered as configuration options (…
…true by default) for the table styling.
  • Loading branch information
Shahmir Noorani committed May 16, 2016
commit e30aeb11bf88570223b720c769f1b88fd171e792
16 changes: 13 additions & 3 deletions components/table/ng-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Directive, EventEmitter, ElementRef, Renderer} from '@angular/core';
import {Component, Directive, EventEmitter, ElementRef, Renderer, OnInit} from '@angular/core';
import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgFor} from '@angular/common';

import {NgTableSorting} from './ng-table-sorting.directive';
Expand All @@ -8,7 +8,7 @@ import {NgTableSorting} from './ng-table-sorting.directive';
inputs: ['rows', 'columns', 'config'],
outputs: ['tableChanged'],
template: `
<table class="table table-striped table-bordered dataTable"
<table class="table dataTable" [ngClass]="{'table-striped': config.striped, 'table-bordered': config.bordered}"
role="grid" style="width: 100%;">
<thead>
<tr role="row">
Expand All @@ -28,12 +28,22 @@ import {NgTableSorting} from './ng-table-sorting.directive';
`,
directives: [NgTableSorting, NgClass, CORE_DIRECTIVES, FORM_DIRECTIVES]
})
export class NgTable {
export class NgTable implements OnInit {
// Table values
public rows:Array<any> = [];
private _columns:Array<any> = [];
public config:any = {};

ngOnInit() {
if (this.config.striped === undefined) {
this.config.striped = true;
}

if (this.config.bordered === undefined) {
this.config.bordered = true;
}
}

// Outputs (Events)
public tableChanged:EventEmitter<any> = new EventEmitter();

Expand Down
2 changes: 1 addition & 1 deletion demo/components/table/table-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[ngTableFiltering]="config.filtering"
(tableChanged)="onChangeTable(config)"/>

<ngTable [config]="config.sorting"
<ngTable [config]="config.table"
(tableChanged)="onChangeTable(config)"
[rows]="rows" [columns]="columns">
</ngTable>
Expand Down
8 changes: 6 additions & 2 deletions demo/components/table/table-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export class TableDemo implements OnInit {

public config:any = {
paging: true,
sorting: {columns: this.columns},
filtering: {filterString: '', columnName: 'position'}
filtering: {filterString: '', columnName: 'position'},
table: {
columns: this.columns,
striped: true,
bordered: true
}
};

private data:Array<any> = TableData;
Expand Down