l-lin / angular-datatables

DataTables with Angular
https://l-lin.github.io/angular-datatables/
MIT License
1.57k stars 486 forks source link

pageLength not working as expected in angular datatable server side response #1646

Closed srijanlama closed 2 years ago

srijanlama commented 2 years ago

:beetle: bug report

pageLength = 2 not returning expected result on datatable

  ngOnInit(): void {
    const that = this;
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 2, // this should return datatable of page length 2 
      serverSide: true,
      processing: true,
      ajax: (dataTablesParameters: any, callback) => {
        that.http
          .post<DataTablesResponse>(
            environment.api_url + `job/manpower`,
            dataTablesParameters,
            {}
          )
          .subscribe((res: any) => {
            that.jobs = res.data;
            callback({
              recordsTotal: res.recordsTotal,
              data: [],
            });
          });
      },
      columns: [{ data: 'id' }, { data: 'title.en' }],
    };
  }

server api response

api-data

request payload

payload

datatables shows more than 2 records

SajhajobsFrontend

any help is Appreciated Sri Zn