l-lin / angular-datatables

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

dtTrigger and SetTime Server Side Rendering #1211

Closed muralimnmcse closed 3 years ago

muralimnmcse commented 6 years ago

In angular way when i use dtTrigger and SetTimeout Server Side Rendering, no data message is not shown.

I'm submitting a...

Bug

What versions you are using?


- node version: 8.9.0
- angular version: 5.0.1
- angular-cli version: 1.7.3
- jquery version: 3.2.1
- datatables version: 1.10.16
- angular-datatables version: 5.0.0

Current behavior

When i use dtTrigger inside settimeout "No data" message is not shown when the data array is empty

Expected behavior

When i use dtTrigger inside settimeout "No data" message to be shown when the data array is empty

Minimal reproduction of the problem with instructions

if (this.dtElement && this.dtElement.dtInstance) {
          this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
            // Destroy the table first
            dtInstance.destroy();
          });
        }

        this.dtOptions = {
          pagingType: 'full_numbers',
          processing: true,
          serverSide: true,
          deferRender: true,
          destroy: true,
          searching: true,
          pageLength: 50,
          ajax: (dataTablesParameters: any, callback) => {
            this.taskService.getasksbyprospectlist(stat_mode, withclosed, dataTablesParameters)
              .subscribe(
                (data) => {
                  this.objlstTasksDataTable = data.data;
                  callback({
                    recordsTotal: data.recordsTotal,
                    recordsFiltered: data.recordsFiltered,
                    data: []
                  });
                },
                error => {
                  this.alertService.error(error);
                });
          },
          columns: [
            { data: 'id', name: 'id', defaultContent: '', orderable: true, searchable: true },
            {
              data: 'firstname',
              defaultContent: '',
              orderable: true,
              searchable: true,
            },
            {
              data: 'lastname',
              defaultContent: '',
              orderable: true,
              searchable: true,
            },
            { data: 'type', name: 'type', defaultContent: '', orderable: true, searchable: true },
            { data: 'starteddatetime', name: 'starteddatetime', defaultContent: '', orderable: true, searchable: true },
            { data: 'enddatetime', name: 'enddatetime', defaultContent: '', orderable: true, searchable: true },
            { data: 'status', name: 'status', defaultContent: '', orderable: true, searchable: true }
          ],
          language: {
            'processing':
              ' Processing... please wait. <i class="fa fa-hourglass-start fa-pulse fa-1x fa-fw" style="color: #00b5e6;"></i>',
          }
        };

        this.timeOutIDs.push(
          setTimeout(() => {
            this.dtTrigger.next();
          }));

Reference: https://l-lin.github.io/angular-datatables/#/basic/server-side-angular-way -->

l-lin commented 6 years ago

What is this.timeOutIDs? Have you tried without the setTimeout?

muralimnmcse commented 6 years ago

this.timeOutIDs is a number array collection to unsubscribe set timeout during OnDestroy. If i dont use set timeout table it self not rendering.

l-lin commented 6 years ago

I don't think you need to use dtTrigger at all. Try it without it (on both the TS and HTML files).

awais2080 commented 5 years ago

dear @l-lin you must have test with angular server side plus rerendring and the dt buttons nothing shows with print csv etc i know this is only rerendrinig problem kindly if you can help with this let me know :(

awais2080 commented 5 years ago

@muralimnmcse is your serverside working properly with print,pdf button

awais2080 commented 5 years ago

hi @muralimnmcse and dear @l-lin after deep hard working with this i found a solution to this serverside rerendering issues i will create a new issue and will resolve it there and will share the link so that you guys can move on

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been closed due to inactivity. Please feel free to re-open the issue to add new inputs.