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

angular 7 server side true dtbuttons having no data  #1369

@awais2080

Description

@awais2080

I'm submitting a...


[ ] Big Unseen  Bug report 
[might be  true ] Feature request 
[ yes ] Documentation issue or request
[ ] Dear i have been struggling with angular datatable serverside for quite a long i have full command without serverside but without serverside its none of use as we cant fetch all data once you are programmer you know memory resources for server is limited. 
problem with this is i tried exactly the same as provided in document for angular server side but result is not positive 

Current behavior

Expected behavior

when button with csv or pdf should be clicked data must be shown there .

Minimal reproduction of the problem with instructions

ID First name Last name
{{ person.id }} {{ person.firstName }} {{ person.lastName }}
No data!

import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { DataTableDirective } from 'angular-datatables';
class Person {
id: number;
firstName: string;
lastName: string;
}

class DataTablesResponse {
data: any[];
draw: number;
recordsFiltered: number;
recordsTotal: number;
}
@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'dtserver';
dtOptions: DataTables.Settings = {};
persons: Person[];
constructor(private http: HttpClient) {}
ngOnInit(): void {
const that = this;

this.dtOptions = {
  pagingType: 'full_numbers',
  dom: 'lBfrtip',
  pageLength: 10,
  serverSide: true,
  processing: true,
  ajax: (dataTablesParameters: any, callback) => {
    that.http
      .post<DataTablesResponse>(
        'https://angular-datatables-demo-server.herokuapp.com/',
        dataTablesParameters, {}
      ).subscribe(resp => {
        that.persons = resp.data;

        callback({
          recordsTotal: resp.recordsTotal,
          recordsFiltered: resp.recordsFiltered,
          data: []
        });
      });
  },
  columns: [{ data: 'id' }, { data: 'firstName' }, { data: 'lastName' }]
};

}

}

Environment


- node version:  v10.10
- angular version: 7.2.0
- angular-cli version: 7.2.0
- jquery version: 3.3.1
- datatables version:   1.10.19
- angular-datatables version: 7.0.0

image
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions