- Home
- Forum
- Angular - EJ 2
- deleteRecord does not work in Batch mode
deleteRecord does not work in Batch mode
Dear Syncfusion Team!
I am trying to implement deletion of a row in grid while using batch mode, with no success.
I have searched through the forums, but found no solution.
If I try adding Batch mode to the editSettings in this sample: https://stackblitz.com/edit/angular-kji3cs-n9wplg?file=app.component.css , the Delete button no longer works.
The same happens on the project I am working on.
Is there a workaround for this?
Thank you.
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
RS
Rajapandiyan Settu
Syncfusion Team
May 7, 2021 08:26 AM UTC
Hi Katona,
Thanks for contacting Syncfusion support.
Before proceeding with your requirement, we would like to share the behavior of batch edit in EJ2 Grid.
When you perform CRUD actions in batch mode, all the changes are kept in the virtual mode. i.e. the changes of editing, adding, deleting records are not reflected in Grid’s dataSource.
To save the CRUD changes in the Grid’s dataSource, we need to call the batchSave method or click the Update button of Grid Toolbar. Please find the modified sample and code example for more information.
|
[app.component.ts]
BtnClick2() {
// save the batch changes in Grid
this.grid.editModule.batchSave();
}
|
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S
KD
Katona David
May 7, 2021 09:56 AM UTC
Hello Rajapandiyan !
Thank you for your answer.
My problem is that I don't want to delete the manually selected rows. I need to delete rows by specifying the primary key of the data in the row, like this :
this.grid.deleteRecord('OrderID', 10249);
But it does not delete the specified row.
I tried using the selectRows method and then calling deleteRecord, which deletes the records for a millisecond, but then the rows come back instantly.
RS
Rajapandiyan Settu
Syncfusion Team
May 10, 2021 09:30 AM UTC
Hi Katona,
Thanks for update.
Query: My problem is that I don't want to delete the manually selected rows. I need to delete rows by specifying the primary key of the data in the row
By analyzing your code example, we found that the parameters passed in the deleteRecord method is not in valid format.
If you want to delete a record by programmatic way, then you need to pass two parameters in deleteRecord method of Grid. The first parameter is primaryKey field name (string format) and the second is correspond row data in object format. Please find the below documentation for more information.
|
[app.component.ts]
BtnClick() {
// delete the first record in current page
this.grid.deleteRecord('OrderID', this.grid.currentViewData[0]);
}
|
Note: If fieldname and data is not given then grid will delete the selected record.
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S
Marked as answer
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
KD Katona David
- May 6, 2021 08:46 PM UTC
- May 10, 2021 09:30 AM UTC