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

Commit aef340e

Browse files
authored
Merge pull request #1760 from l-lin/no-server-ajax-callback
chore(demo): show static text on preview for ajax callback
2 parents 0a66237 + bd57553 commit aef340e

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-datatables-demo",
3-
"version": "16.0.0",
3+
"version": "17.0.1",
44
"license": "MIT",
55
"scripts": {
66
"ng": "ng",
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<ng-template #preview>
2-
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
2+
<blockquote>
3+
<p>No preview as we do not have a server that can serve the queries.</p>
4+
</blockquote>
35
</ng-template>
46
<app-base-demo [pageTitle]="pageTitle" [mdIntro]="mdIntro" [mdHTML]="mdHTML" [mdTS]="mdTS" [template]="preview">
57
</app-base-demo>

demo/src/app/basic/with-ajax-callback/with-ajax-callback.component.spec.ts

-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { HttpClientModule } from '@angular/common/http';
22
import { SecurityContext, NO_ERRORS_SCHEMA } from '@angular/core';
33
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
4-
import { By } from '@angular/platform-browser';
54
import { RouterTestingModule } from '@angular/router/testing';
65
import { DataTableDirective, DataTablesModule } from 'angular-datatables';
76
import { AppRoutingModule } from 'app/app.routing';
@@ -50,15 +49,4 @@ describe('WithAjaxCallbackComponent', () => {
5049
expect(app.pageTitle).toBe('AJAX with callback');
5150
}));
5251

53-
it('should have table populated via AJAX', async () => {
54-
const app = fixture.debugElement.componentInstance as WithAjaxCallbackComponent;
55-
await fixture.whenStable();
56-
expect(app.dtOptions.columns).toBeDefined();
57-
const query = fixture.debugElement.query(By.directive(DataTableDirective));
58-
const dir = query.injector.get(DataTableDirective);
59-
expect(dir).toBeTruthy();
60-
const instance = await dir.dtInstance;
61-
fixture.detectChanges();
62-
expect(instance.rows().length).toBeGreaterThan(0);
63-
});
6452
});

demo/src/app/basic/with-ajax-callback/with-ajax-callback.component.ts

-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Component, OnInit } from '@angular/core';
3-
import { DataTablesResponse } from 'app/datatables-response.model';
43

54
@Component({
65
selector: 'app-with-ajax-callback',
@@ -22,19 +21,6 @@ export class WithAjaxCallbackComponent implements OnInit {
2221
ngOnInit(): void {
2322
const that = this;
2423
this.dtOptions = {
25-
ajax: (dataTablesParameters: any, callback) => {
26-
that.http
27-
.post<DataTablesResponse>(
28-
'https://xtlncifojk.eu07.qoddiapp.com/',
29-
dataTablesParameters, {}
30-
).subscribe(resp => {
31-
callback({
32-
recordsTotal: resp.recordsTotal,
33-
recordsFiltered: resp.recordsFiltered,
34-
data: resp.data
35-
});
36-
});
37-
},
3824
columns: [{
3925
title: 'ID',
4026
data: 'id'

0 commit comments

Comments
 (0)