Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82602

angular 7 datatables with observable data from server with pagination (not ajax)

$
0
0

Hello,
I using Angular 7 and data-tables.
I want to use data-table with server-side and paging but use observable data that come from a service

For example:
the ajax call is used like that:

ngOnInit(): void {
    const that = this;
    this.dtOptions = {
      pagingType: 'full_numbers',
      responsive: true,
      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;

I need to use/using

ngOnInit(): void {
    const that = this;
    this.dtOptions = {
      pagingType: 'full_numbers',
      responsive: true,
      serverSide: true,
      processing: true,
      
      this.subscription = this.controllerService.getAdminControllers().subscribe(
      (controllers:{pagination?: Pagination, data?: Controller[]}) => {
        this.controllers = controllers.data;
        console.log(this.controllers);
        this.isWorking = false;
        this.rerender();
      });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.


Viewing all articles
Browse latest Browse all 82602

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>