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.

Delete not working?

See original GitHub issue

When I delete a row, the row disappears from the view, but it is still present in the data source. So when pushing data to server (with source.getAll()), anything has changed.

I am using internal mode, and also, no event is raised when I try to delete it. On settings i have delete.confirmDelete = true;

on html: (deleteConfirm)=“onDeleteConfirm($event)”

on ts:

onDeleteConfirm(event) {
    if (window.confirm('Are you sure you want to save?')) {
      //call to remote api, remember that you have to await this
      event.confirm.resolve(event.newData);
    } else {
      event.confirm.reject();
    }
  }

but it is never called…

Checked everything already in the docs: https://akveo.github.io/ng2-smart-table/#/documentation

Any ideas?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
tarunsinghal92commented, May 13, 2020

There seems to be condition issue at https://github.com/akveo/ng2-smart-table/blob/master/projects/ng2-smart-table/src/lib/lib/data-source/local/local.data-source.ts#L50

For now, here is a hack that should work.

// smart-table config
{
        ...
        actions: {
          delete: true,
          ...
        },
        delete: {
          deleteButtonContent: 'Delete',
          confirmDelete: true
        },
        columns: {...}
}

// define deleteConfirm in element
<ng2-smart-table 
	...
	[settings]="config" 
	[source]="value"
	(deleteConfirm)="onDeleteConfirm($event)"
/>

// write onDeleteConfirm like below
public onDeleteConfirm(event) {
    this.value = event.source.data.filter((d: any) => !isEqual(d, event.data));
    event.confirm.resolve();
  }

isEqual is a lodash function that deep compares both the object.

In short, remove the element urself using the datasource.

0reactions
mohammad0omarcommented, Apr 3, 2020

why pushing all the data to the server? when the delete method is called the just send the id deleted to the backend

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Fixed] Delete Key Not Working in Windows 10 [Partition Magic]
Fix 1: Run the Windows Troubleshooter · Fix 2: Update, Roll Back or Uninstall the Keyboard Driver · Fix 3: Uninstall the Recently...
Read more >
Delete key not working - Microsoft Community
Check which Updates were installed at Settings > Update & Security > Windows Update > Installed Update History and try uninstalling any from ......
Read more >
Delete button on keyboard working, but not deleting - Dell
However when I press shift and DEL button,, it works,,, so to if I press CTRL ALT+DEL to get into Task Mgr.
Read more >
[SOLVED] - Delete Key not working - Tom's Hardware Forum
Hi, My Delete key is not working, I'm on latest version of Windows 10, tried external keyboard & On-screen keyboard delete keys, ...
Read more >
Delete key is not working - Super User
To solve the problem, first plug out all USB devices, including small dongles and see if the problem goes away or not. If...
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