Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

chore(demo): show static text on preview for ajax callback #1760

Merged
merged 2 commits into from
Nov 13, 2023
Merged
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
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-datatables-demo",
"version": "16.0.0",
"version": "17.0.1",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<ng-template #preview>
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
<blockquote>
<p>No preview as we do not have a server that can serve the queries.</p>
</blockquote>
</ng-template>
<app-base-demo [pageTitle]="pageTitle" [mdIntro]="mdIntro" [mdHTML]="mdHTML" [mdTS]="mdTS" [template]="preview">
</app-base-demo>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpClientModule } from '@angular/common/http';
import { SecurityContext, NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { DataTableDirective, DataTablesModule } from 'angular-datatables';
import { AppRoutingModule } from 'app/app.routing';
Expand Down Expand Up @@ -50,15 +49,4 @@ describe('WithAjaxCallbackComponent', () => {
expect(app.pageTitle).toBe('AJAX with callback');
}));

it('should have table populated via AJAX', async () => {
const app = fixture.debugElement.componentInstance as WithAjaxCallbackComponent;
await fixture.whenStable();
expect(app.dtOptions.columns).toBeDefined();
const query = fixture.debugElement.query(By.directive(DataTableDirective));
const dir = query.injector.get(DataTableDirective);
expect(dir).toBeTruthy();
const instance = await dir.dtInstance;
fixture.detectChanges();
expect(instance.rows().length).toBeGreaterThan(0);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { DataTablesResponse } from 'app/datatables-response.model';

@Component({
selector: 'app-with-ajax-callback',
Expand All @@ -22,19 +21,6 @@ export class WithAjaxCallbackComponent implements OnInit {
ngOnInit(): void {
const that = this;
this.dtOptions = {
ajax: (dataTablesParameters: any, callback) => {
that.http
.post<DataTablesResponse>(
'https://xtlncifojk.eu07.qoddiapp.com/',
dataTablesParameters, {}
).subscribe(resp => {
callback({
recordsTotal: resp.recordsTotal,
recordsFiltered: resp.recordsFiltered,
data: resp.data
});
});
},
columns: [{
title: 'ID',
data: 'id'
Expand Down