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

Emit onDataFilled event for notifying when data has been recomputed #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export {DataTable, DataEvent, PageEvent, SortEvent} from './lib/DataTable';
export {DataTable, PageEvent, SortEvent, DataEvent} from './lib/DataTable';
export {DefaultSorter} from './lib/DefaultSorter';
export {Paginator} from './lib/Paginator';
export {BootstrapPaginator} from './lib/BootstrapPaginator';
export {DataTableModule} from './lib/DataTableModule';
export {DataTableModule} from './lib/DataTableModule';
2 changes: 1 addition & 1 deletion src/DataTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,4 @@ describe("DataTable directive tests", ()=> {
expect(datatable.activePage).toEqual(1);
});
});
});
});
8 changes: 6 additions & 2 deletions src/DataTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface PageEvent {
}

export interface DataEvent {
length: number;
currentData: any[];
}

@Directive({
Expand All @@ -43,6 +43,7 @@ export class DataTable implements OnChanges, DoCheck {

public onSortChange = new ReplaySubject<SortEvent>(1);
public onPageChange = new EventEmitter<PageEvent>();
public onDataFilled = new EventEmitter<DataEvent>();

public constructor(private differs: IterableDiffers) {
this.diff = differs.find([]).create(null);
Expand Down Expand Up @@ -147,6 +148,9 @@ export class DataTable implements OnChanges, DoCheck {
}
data = _.slice(data, offset, offset + this.rowsOnPage);
this.data = data;
this.onDataFilled.emit({
currentData: data
});
}

private caseInsensitiveIteratee(sortBy: string) {
Expand All @@ -163,4 +167,4 @@ export class DataTable implements OnChanges, DoCheck {
return value;
};
}
}
}