This repository was archived by the owner on Feb 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 16 files changed +267
-1
lines changed Expand file tree Collapse file tree 16 files changed +267
-1
lines changed Original file line number Diff line number Diff line change 4141 < li >
4242 < a class ="waves-effect waves-blue " routerLink ="/basic/with-options "> With options</ a >
4343 </ li >
44+ < li >
45+ < a class ="waves-effect waves-blue " routerLink ="/basic/with-ajax-callback "> AJAX using DT callback</ a >
46+ </ li >
47+ < li >
48+ < a class ="waves-effect waves-blue " routerLink ="/basic/new-server-side "> Server side</ a >
49+ </ li >
4450 < li >
4551 < a class ="waves-effect waves-blue " routerLink ="/advanced/row-click-event "> Row click event</ a >
4652 </ li >
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ import { FAQComponent } from './f-a-q/f-a-q.component';
4646import { UsingNgTemplateRefComponent } from './advanced/using-ng-template-ref.component' ;
4747import { DemoNgComponent } from './advanced/demo-ng-template-ref.component' ;
4848import { MoreHelpComponent } from './more-help/more-help.component' ;
49+ import { WithAjaxCallbackComponent } from './basic/with-ajax-callback/with-ajax-callback.component' ;
50+ import { NewServerSideComponent } from './basic/new-server-side/new-server-side.component' ;
4951
5052@NgModule ( {
5153 declarations : [
@@ -78,7 +80,9 @@ import { MoreHelpComponent } from './more-help/more-help.component';
7880 FAQComponent ,
7981 UsingNgTemplateRefComponent ,
8082 DemoNgComponent ,
81- MoreHelpComponent
83+ MoreHelpComponent ,
84+ WithAjaxCallbackComponent ,
85+ NewServerSideComponent
8286 ] ,
8387 imports : [
8488 BrowserModule ,
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ import { UsingNgPipeComponent } from './advanced/using-ng-pipe.component';
2828import { FAQComponent } from './f-a-q/f-a-q.component' ;
2929import { UsingNgTemplateRefComponent } from './advanced/using-ng-template-ref.component' ;
3030import { MoreHelpComponent } from './more-help/more-help.component' ;
31+ import { WithAjaxCallbackComponent } from './basic/with-ajax-callback/with-ajax-callback.component' ;
32+ import { NewServerSideComponent } from './basic/new-server-side/new-server-side.component' ;
3133
3234const routes : Routes = [
3335 {
@@ -63,6 +65,14 @@ const routes: Routes = [
6365 path : 'basic/with-ajax' ,
6466 component : WithAjaxComponent
6567 } ,
68+ {
69+ path : 'basic/with-ajax-callback' ,
70+ component : WithAjaxCallbackComponent
71+ } ,
72+ {
73+ path : 'basic/new-server-side' ,
74+ component : NewServerSideComponent
75+ } ,
6676 {
6777 path : 'basic/angular-way' ,
6878 component : AngularWayComponent
Original file line number Diff line number Diff line change 1+ < ng-template #preview >
2+ < table datatable [dtOptions] ="dtOptions " class ="row-border hover "> </ table >
3+ </ ng-template >
4+ < app-base-demo [pageTitle] ="pageTitle " [mdIntro] ="mdIntro " [mdHTML] ="mdHTML " [mdTS] ="mdTS " [template] ="preview ">
5+ </ app-base-demo >
Original file line number Diff line number Diff line change 1+ import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2+
3+ import { NewServerSideComponent } from './new-server-side.component' ;
4+
5+ describe ( 'NewServerSideComponent' , ( ) => {
6+ let component : NewServerSideComponent ;
7+ let fixture : ComponentFixture < NewServerSideComponent > ;
8+
9+ beforeEach ( async ( ) => {
10+ await TestBed . configureTestingModule ( {
11+ declarations : [ NewServerSideComponent ]
12+ } )
13+ . compileComponents ( ) ;
14+
15+ fixture = TestBed . createComponent ( NewServerSideComponent ) ;
16+ component = fixture . componentInstance ;
17+ fixture . detectChanges ( ) ;
18+ } ) ;
19+
20+ it ( 'should create' , ( ) => {
21+ expect ( component ) . toBeTruthy ( ) ;
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change 1+ import { HttpClient } from '@angular/common/http' ;
2+ import { Component , OnInit } from '@angular/core' ;
3+ import { DataTablesResponse } from 'app/datatables-response.model' ;
4+
5+ @Component ( {
6+ selector : 'app-new-server-side' ,
7+ templateUrl : './new-server-side.component.html' ,
8+ styleUrls : [ './new-server-side.component.css' ]
9+ } )
10+ export class NewServerSideComponent implements OnInit {
11+
12+ constructor (
13+ private http : HttpClient
14+ ) { }
15+
16+ pageTitle = 'Server-side processing' ;
17+ mdIntro = 'assets/docs/basic/new-server-side/intro.md' ;
18+ mdHTML = 'assets/docs/basic/new-server-side/source-html.md' ;
19+ mdTS = 'assets/docs/basic/new-server-side/source-ts.md' ;
20+
21+ dtOptions : DataTables . Settings = { } ;
22+
23+ ngOnInit ( ) : void {
24+ const that = this ;
25+ this . dtOptions = {
26+ serverSide : true ,
27+ ajax : ( dataTablesParameters : any , callback ) => {
28+ that . http
29+ . post < DataTablesResponse > (
30+ 'https://xtlncifojk.eu07.qoddiapp.com/' ,
31+ dataTablesParameters , { }
32+ ) . subscribe ( resp => {
33+ callback ( {
34+ recordsTotal : resp . recordsTotal ,
35+ recordsFiltered : resp . recordsFiltered ,
36+ data : resp . data
37+ } ) ;
38+ } ) ;
39+ } ,
40+ columns : [ {
41+ title : 'ID' ,
42+ data : 'id'
43+ } , {
44+ title : 'First name' ,
45+ data : 'firstName'
46+ } , {
47+ title : 'Last name' ,
48+ data : 'lastName'
49+ } ]
50+ } ;
51+ }
52+ }
53+
Original file line number Diff line number Diff line change 1+ < ng-template #preview >
2+ < table datatable [dtOptions] ="dtOptions " class ="row-border hover "> </ table >
3+ </ ng-template >
4+ < app-base-demo [pageTitle] ="pageTitle " [mdIntro] ="mdIntro " [mdHTML] ="mdHTML " [mdTS] ="mdTS " [template] ="preview ">
5+ </ app-base-demo >
Original file line number Diff line number Diff line change 1+ import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2+
3+ import { WithAjaxCallbackComponent } from './with-ajax-callback.component' ;
4+
5+ describe ( 'WithAjaxCallbackComponent' , ( ) => {
6+ let component : WithAjaxCallbackComponent ;
7+ let fixture : ComponentFixture < WithAjaxCallbackComponent > ;
8+
9+ beforeEach ( async ( ) => {
10+ await TestBed . configureTestingModule ( {
11+ declarations : [ WithAjaxCallbackComponent ]
12+ } )
13+ . compileComponents ( ) ;
14+
15+ fixture = TestBed . createComponent ( WithAjaxCallbackComponent ) ;
16+ component = fixture . componentInstance ;
17+ fixture . detectChanges ( ) ;
18+ } ) ;
19+
20+ it ( 'should create' , ( ) => {
21+ expect ( component ) . toBeTruthy ( ) ;
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change 1+ import { HttpClient } from '@angular/common/http' ;
2+ import { Component , OnInit } from '@angular/core' ;
3+ import { DataTablesResponse } from 'app/datatables-response.model' ;
4+
5+ @Component ( {
6+ selector : 'app-with-ajax-callback' ,
7+ templateUrl : './with-ajax-callback.component.html'
8+ } )
9+ export class WithAjaxCallbackComponent implements OnInit {
10+
11+ constructor (
12+ private http : HttpClient
13+ ) { }
14+
15+ pageTitle = 'AJAX with callback' ;
16+ mdIntro = 'assets/docs/basic/with-ajax-callback/intro.md' ;
17+ mdHTML = 'assets/docs/basic/with-ajax-callback/source-html.md' ;
18+ mdTS = 'assets/docs/basic/with-ajax-callback/source-ts.md' ;
19+
20+ dtOptions : DataTables . Settings = { } ;
21+
22+ ngOnInit ( ) : void {
23+ const that = this ;
24+ 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+ } ,
38+ columns : [ {
39+ title : 'ID' ,
40+ data : 'id'
41+ } , {
42+ title : 'First name' ,
43+ data : 'firstName'
44+ } , {
45+ title : 'Last name' ,
46+ data : 'lastName'
47+ } ]
48+ } ;
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments