bulk edit table after update

Questionsbulk edit table after update
jiga asked 6 years ago

Hi I would like to know how to do the following:
I have a bulk edit grid wich I use to edit multiple rows, what I want to do is to perform an action on other table after bulk editng
For example
Table A
I edit row 1,2,3 with pk pk1,pk2,etc I change colum status to “OK”
My grid works fine here but next I need to update other table with same values
Table B
row with pk1,pk2, etc should also update to “OK”

$e[“on_after_update”] = array(“after_update”, null, true);
$g->set_events($e);
function after_update()
{
my problem is here i guess I dont know how to adapt the bulkedit documentation to my problem
}

full code

$col = array();
$col[“title”] = “ID”;
$col[“name”] = “id”;
$col[“width”] = “20”;
$col[“align”] = “center”;
$col[“editable”] = false;
$col[“hidden”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “<i class=’fas fa-building’></i> GRUPO”;
$col[“name”] = “grupo”;
$col[“width”] = “25”;
$col[“align”] = “center”;
$col[“editable”] = true;
$col[“resizable”] = false;
$cols[] = $col;

$col = array();
$col[“title”] = “<i class=’fas fa-pencil-alt’></i> NOMBRE”;
$col[“name”] = “nombre”;
$col[“width”] = “80”;
$col[“align”] = “center”;
$col[“editable”] = false;
$col[“resizable”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “<i class=’fas fa-file-alt’></i> CURP”;
$col[“name”] = “curp”;
$col[“width”] = “50”;
$col[“align”] = “center”;
$col[“editable”] = false;
$col[“resizable”] = true;
$cols[] = $col;

$grid[“rowList”] = array(10,20,30,40,50,’All’);
$grid[“autowidth”] = false;
$grid[“sortable”] = true;
$grid[“rowNum”] = 16;
$grid[“rownumbers”] = true;
$grid[“rownumWidth”] = 30;
$grid[“forceFit”] = true;
$grid[“shrinkToFit”] = true;
$grid[“resizable”] = true;
$grid[“autoresize”] = true;
$grid[“multiselect”] = true;
$grid[“altRows”] = true;
$grid[“cellEdit”] = true;
$grid[“reloadedit”] = true;
$grid[“caption”] = “<i class=’fas fa-users’></i> CONTROL ESCOLAR – ALUMNOS”;
$grid[“loadtext”] = “<i class=’fa fa-spinner fa-2x fa-spin’></i> Buscando coindicencias …”;
$grid[“sortname”] = ‘grupo’; //TEN CUIDADO CON ESTOS TE PUEDEN CAUSAR PROBLEMAS EN LAS CONSULTAS
$grid[“sortorder”] = “asc”;
$grid[“add_options”][“jqModal”] = true;
$grid[“add_options”][“modal”] = true;
$grid[“edit_options”][“jqModal”] = true;
$grid[“edit_options”][“modal”] = true;
$grid[“edit_options”][“checkOnSubmit”] = true;
$grid[“add_options”][“success_msg”] = “<i class=’fa fa-check’></i> Registro agregado exitosamente”;
$grid[“edit_options”][“success_msg”] = “<i class=’fa fa-check’></i> Registro modificado exitosamente”;
$grid[“delete_options”][“success_msg”] = “<i class=’fa fa-check’></i> Registro eliminado exitosamente”;

$e[“on_after_update”] = array(“after_update”, null, true);
$g->set_events($e);
function after_update()
{
$consulta=$connect->prepare(“UPDATE calificaciones{$ciclo_anos} SET grupo =’11’ WHERE curp =’AACD040404HVZBVVA6′”);
$consulta->execute();
}

$g->set_actions(array(“bulkedit”=>true,”add”=>false,”edit”=>true,”delete”=>false,”view”=>true,”search” => “advance”,));
$g->set_options($grid);
$g->select_command = “SELECT id,grupo,nombre,curp FROM buho3448_econ.alumnos”.$ciclo_anos.” WHERE status =’A'”;
$g->table = “buho3448_econ.alumnos”.$ciclo_anos;
$g->set_columns($cols,true);
$out = $g->render(“list1”);

1 Answers
Abu Ghufran Staff answered 6 years ago

You can try …

 

function after_update()
{
$selected_ids = $data[“id”];

// check if bulk updated
if (count(explode(“,”,$selected_ids)) > 1)
{
// run your query to update other table
}
}

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

2 + 2 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?