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.

Responsive extension not working with server side anguar way

See original GitHub issue

I tried to implement server side angular way with responsive extension. I followed all the steps given in example at Responsive Extension.

But it is not working. I applied class ‘none’ to the first column in ‘th’ of the html. Header column name is hiding but column stay as it is. I also tried with adding columns to the dtoptions.

drivers: Driver[] = [];

this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 10,
      processing: true,
      serverSide: true,
      language: {
        infoEmpty: AppSettings.EmptyDataTableMessage,
      },     
      responsive: true,     
      ajax: (dataTablesParameters: any, callback) => {
        let pageOffset = dataTablesParameters.start;
        let pageSize = dataTablesParameters.length;
        let searchText = dataTablesParameters.search != null ? dataTablesParameters.search.value : '';
        this._driverService.getAllDrivers(pageOffset, pageSize, searchText).subscribe(response => {
          this.drivers = response;
          callback({
            recordsTotal: response.length > 0 ? response[0].RecordsTotal : 0,
            recordsFiltered: response.length > 0 ? response[0].RecordsTotal : 0,
            data: []
          });
        });
      },
    };

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11

github_iconTop GitHub Comments

2reactions
aleperfetti81commented, Feb 6, 2019

I confirm that server side the angular way broke responsive. The @kettunen solution is fine. I’ve another working solution:

TS file:

dtOptions: DataTables.Settings = {};
  viewAnagrafiche: [] = [];

  // We use this trigger because fetching the list of persons can be quite long,
  // thus we ensure the data is fetched before rendering
  dtTrigger: Subject<any> = new Subject();

ngOnInit() {
    this.loadTable(); 
  }

ngAfterViewInit(): void {
    this.dtTrigger.next();    
  }

loadTable(){
    const that = this;

    let rq = new ElencoAnagraficheFormRQ();


    this.dtOptions = {
      serverSide: true,
      processing: true,
      search: false,
      responsive: true,
      order: [1],
      ajax: (dataTablesParameters: any, callback, settings) => {

        rq.dataTablesInput = dataTablesParameters;
        
        that.anagraficaService.getElencoAnagraficheForm(rq).subscribe(
          
          x => {
            if (x) {
              that.viewAnagrafiche = x.dataTableResult.data;

              callback({
                recordsTotal: x.dataTableResult.recordsTotal,
                recordsFiltered: x.dataTableResult.recordsFiltered,
                data: x.dataTableResult.data
              });

              this.dataTableService.attachClickEvent(".btn-seleziona", this.selectAnagrafica, that);
            }
          },
          error => {
            this.showGenericError(error);
          });
      },
      columns: this.getColumns()
    };
  }

Template:

<table datatable appDataTables [dtTrigger]="dtTrigger" [dtOptions]="dtOptions" style="width: 100%"
                        class="table">
                        <thead>
                            <tr>
                                <th></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.ragioneSociale' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.agenzia' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.codiceFiscale' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.partitaIva' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.citta' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.provincia' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.cellulare' | translate}}</span></th>
                                <th><span>{{ 'customers.elencoAnagraficheForm.email' | translate}}</span></th>
                            </tr>
                        </thead>
                    </table>
1reaction
AArayeshicommented, Feb 26, 2019

@aleperfetti81 your solution is not angular way. it is just server side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular DataTable Responsive Extension not working for ...
i am trying to implement https://l-lin.github.io/angular-datatables/#/extensions/responsive but its not working. have anyone done this ...
Read more >
Responsive is not working with Angular 8 implementation
Description of problem: Im using Datatables Angular implementation. It works fine with the defaults options and language style (spanish), but ...
Read more >
Responsive Server Side 1264 - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >
Server-side rendering (SSR) with Angular Universal
A normal Angular application executes in the browser, rendering pages in the DOM in response to user actions. Angular Universal executes on the...
Read more >
Angular DataTables - l-lin
Features: · Quick Install · Angular Pipes support · Large dataset support · Advanced Data Filter · Extensions support · MIT.
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