Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Mass Deletion
-
- Posts: 11
- Joined: Sun Feb 04, 2018 7:18 am
Mass Deletion
Any pointers on how to add Browse Action Button that can delete all selected records (based on search)
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Mass Deletion
Something like this could work:
Set a Hash Cookie like:
Use nuRunPHPHidden() to run a PHP procedure.
This PHP Procedure would then run a query to retrieve the primary keys of the (filtered rows)
Next, you would have to build a delete statement to delete all rows that match these primary keys.
I know it may be a bit abstract, but it should work that way.
Set a Hash Cookie like:
Code: Select all
nuSetProperty('browsesql', nuCurrentProperties().browse_sql);
This PHP Procedure would then run a query to retrieve the primary keys of the (filtered rows)
Code: Select all
$s = "#browsesql#";
$t = nuRunQuery($s);
...
...
I know it may be a bit abstract, but it should work that way.
Re: Mass Deletion
redmonk,
You could give this a go.
Add this to the Javascript of the Form...
And add this to Before Browse...
Steven
You could give this a go.
Add this to the Javascript of the Form...
Code: Select all
nuAddActionButton('deleteGroup', 'Delete Unfiltered Records', 'deleteWhere()');
function deleteWhere(){
if (confirm("Are you sure you want to delete all unfiltered records?")){
nuSetProperty('deleteFiltered', '1');
$('#nuSearchButton').click();
nuSetProperty('deleteFiltered', '0');
}
}
Code: Select all
if(nuHash()['deleteFiltered'] == '1'){
$sql = nuHash()['browse_sql'];
$w = strpos($sql, 'WHERE');
$o = strpos($sql, 'ORDER BY');
$o = !$o ? 10000 : $o;
$s = substr($sql, $w, $o - $w);
$s = str_replace('\\', '', $s);
nuRunQuery('DELETE FROM theteblename ' . $s);
}
Steven