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.

ngx-datatable not updating the footer's selected count message

See original GitHub issue

I’m submitting a … (check one with “x”)

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior When I am deleting rows from the table, the footer selected count message does not get updated when clearing the data and fetching the data again. Only the total rows message gets update…

Expected behavior The selected count message should get updated if they user is clearing the selected list.

is like this: 1 selected / 8 total --> but it should be like this: 0 selected / 7 total

Reproduction of the problem Create a table set the [selectionType]=“‘checkbox’”, and (select)=“onSelectItem($event)”

onSelectItem(selectedItems) {
    this.selectedItemList.splice(0, this.selectedItemList.length);
    this.selectedItemList.push(...selectedItems.selected);
}

Select some items in the table(they will be added to the selectedItemList. Delete the selected items, clear the selectedItemList and fetch the data again. The footer’s select count message is not getting updated only the total count message.

What is the motivation / use case for changing the behavior? The footer’s select count message needs to get updated together with the total count message.

Please tell us about your environment: Windows 7

  • Table version: 0.7.x 7.3.0

  • Angular version: 2.0.x Angular 4.0.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] Chrome 55.0.2883.87 m (64-bit)

  • Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript 2.2.1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
yamiicommented, Feb 10, 2018

I’ve encountered this issue and here’s how I solve it. in your template

<ngx-datatable
    [rows]="rows"
    [loadingIndicator]="loading"
    [columns]="columns"
    [selected]="selected" 
    [selectionType]="'checkbox'"
   ---- other settings 
>

on your deleted handler

export class SomeComponent implements onInit {
  selected = []

  onDelete() {
      // after successful delete
      this.selected = []
   }
}

your footer count will reset to zero when setting this.selected = []

ngx-datatable Footer component uses selected variable for its selected count https://github.com/swimlane/ngx-datatable/blob/3ac29923fecee83633fa77966fc74d2357d0c610/src/components/datatable.component.ts#L96

0reactions
kdbeercommented, Apr 6, 2019

My method

On your component let add more variable checkAll = false;

On your selected handler function `

onSelect(e, checkAll) {
    this.selected = e.selected.filter(m => 'Your Condition' );
    this.checkAll = checkAll;
    if (!checkAll) {
        this.selected = [];
        return;
    }
}

`

On Your Template (select)="onSelect($event, !checkAll)"

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngx-datatable not updating the footer's selected count message
When I am deleting rows from the table, the footer selected count message does not get updated when clearing the data and fetching...
Read more >
ngx-datatable-footer does not work in Angular Aplication
In my angular application was installed the ngx-datatable component, when mounting a test I got it simple everything occurred as expected, ...
Read more >
Inputs - ngx-datatable - GitBook
count. Total count of all rows. Default value: 0 ... Footer selected message ... When virtual scrolling is not in use, you can...
Read more >
Ionic 5 ngx-datatable Tutorial Advanced - Appery.io
Open the Pages > Screen1 DESIGN panel. Now, use the Breadcrumbs to select the Page component. Then, under its PROPERTIES panel, set the...
Read more >
@swimlane/ngx-datatable@20.1.0 - jsDocs.io
ngx -datatable is an Angular table grid component for presenting large ... Updates the index of the rows in the viewport ... Gets...
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