Skip to content

Conversation

@frknakk
Copy link
Contributor

@frknakk frknakk commented Nov 6, 2023

Now that there is a feature for additional scripts, here is a script I have been using for a long time.

Problem: When batch removing many rows via Editor, and the rows contain large amounts of data, the remove requests become slow and sometimes even fail due to server limits.

That's because Datatables adds all the column data to the remove request, which is unnecessary in most of the cases. This script modifies the data before it's sent to the server and removes all data from it except the DT_RowId, which is enough for the removal. This results in a more stable and efficient batch removal.

Usage:

/**
 * Optional method if you want to use the html builder.
 */
public function html(): HtmlBuilder
{
	return $this->builder()
		[...]
		->addScript('datatables::functions.batch_remove');
}

@frknakk frknakk changed the title Added batch remove script feat: add batch remove optimization script (optional) Nov 6, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@yajra
Copy link
Owner

yajra commented Nov 6, 2023

Great idea, love it!

Had the same struggle and I think what I did was to use something like "submit only changed" option but the request is still big, especially for very large rows.

@yajra yajra merged commit 2d0c957 into yajra:master Nov 6, 2023
@yajra
Copy link
Owner

yajra commented Nov 6, 2023

Released on v10.11.0 🚀 Thanks!

Feel free to submit a PR if you can for docs 🍻 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants