question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dataTable not sending any parameters in angular 6

See original GitHub issue

Hi i have followed the on of your server side angular way tutorial everything is working fine except the parameters, Whenever i do click on pagination the pagination changed but onCallback first 10 data shows every time. this is because when i am hitting api it sends no parameter with it so it always return the same data. This is api which hit every time http://example.test/webapi/?io=masterpro&action=lst&value=&regex=false

as you can see it not sending any parameters with it that’s why it always returns the first 10 data as i set the length of data to 10 in my api file


import { Component, OnInit } from '@angular/core';
import { adminLteConf } from '../admin-lte.conf';
import {Http} from "@angular/http";
import { HttpClient, HttpResponse } from '@angular/common/http';

import { HttpHeaders } from '@angular/common/http';
import { DataTableDirective } from 'angular-datatables';

@Component({
  selector: 'app-listmasterlog',
  templateUrl: './listmasterproducts.component.html',
  styleUrls: ['./listmasterproducts.component.css']
})
export class ListmasterproductsComponent implements OnInit {

  public data: any[];
  public filterQuery = "";
  public mfRowsOnPage = 10;
  public mfActivePage: any;
  public sortOrder = "asc";

  dtOptions: DataTables.Settings = {}; 
  metaData:any;


  constructor(private http: Http) { }

  ngOnInit(): void {
    this.dtOptions = {
      //pagingType: 'full_numbers',

      processing: true,
      serverSide: true,

      pageLength:10,
      language: {
        lengthMenu: "_MENU_",
        paginate: {
          first:'',
          last:'',
          next: '', // or '→'
          previous: '' // or '←' 
        }
      },
      dom: '<t><"bottom"p><"inline-flex" li><"clear">',
      ajax:(dataTablesParameters:any, callback) => {
        this.http.get(
          adminLteConf.APIURL+"?io=masterpro&action=lst",
          dataTablesParameters
        ).subscribe(resp=> {
          var resposnse = resp.json();
          this.data = resposnse['data'];
          //console.log(this.packages);

          callback({
            recordsTotal: resposnse['meta'].total,
            recordsFiltered: resposnse['meta'].pages,
            data: []
          });
        });
      }
      // columns: [
      //   { data: "RecordId"}, {data: 'PackageName'}, {data: 'Price'}
      // ],
    };



  }

}

The above is in my component file I am using angular 6 and i haven’t find any tutorial which helped me with this so please show me some path or give me some solution for this. I am stuck in this stuff from last 4 or 5 days and it is very urgent to me

this is the image of my table below

screenshot_1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:58

github_iconTop GitHub Comments

3reactions
jayantsr83commented, Sep 10, 2018

Hey @awais2080 my code is working now please tell me if you want that

1reaction
funlabscloudcommented, Sep 20, 2018

Issue fixed for me. setTimeout(() => { this.dtTrigger.next(); });

added before dtOptions

Read more comments on GitHub >

github_iconTop Results From Across the Web

dataTable parameters not working in angular 6
Well i have made some changes and yes my code is working now. It is passing parameter with url. Below is my updated...
Read more >
Datatable Server Side in Angular doesn't show results
I receive all the results properly, I just can't seem to display them properly. A sample result from my network:
Read more >
Angular 6 datatable serverside ajax request not working
I have written web api in c# to get the data in desired format. With following dtoptions, server side is working fine. dtOptions...
Read more >
Angular Data Grid: Get Started with AG Grid
In this video we detail the steps to get an application working with Angular and AG Grid Community. We show how to set...
Read more >
Table
The mat-table provides a Material Design styled data-table that can be used ... Note that this list of columns provided to the rows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found