Calling a DB procedure with the click of a button

QuestionsCalling a DB procedure with the click of a button
Santosh Sankhar asked 2 years ago

Hello,

I implemented a subgrid and added the virtual column “Mover” that contains two buttons. Each one of this buttons should call a procedure that is stored in the database. Those database procedures work correctly already, and I also checked that the functions attached to those buttons are correctly receiving the ID (via alerts).

The code for the “Mover column” has the following default value:

$col[“default”] = “<button onclick=’moveDown({id})’ class=’btn’> <i class=’fa fa-arrow-down’></i></button>
                    <button onclick=’moveDown({id})’ class=’btn’> <i class=’fa fa-arrow-up’></i></button>”;

My question is: How can i call my database procedures inside the function, with a syntax similar to the one used inside “on_insert” events? E.G. $subgrid->execute_query(“CALL moveUp(id);”);

 

Thanks in advance, and I hope my question is well formulated

1 Answers
Abu Ghufran Staff answered 2 years ago

Hi,

I’ve explained similar question here: https://www.gridphp.com/support/questions/change-the-order-in-which-rows-are-presented/

Inside the moveDown(123) JS function, you can call a bulk update function to pass the ID and operation to backend. e.g.

function moveDown(id) {
fx_bulk_update('move-down',id,-1);
}

And now in server side code, you can connect an on_update event handler and use this operation label:
https://www.gridphp.com/demo/demos/editing/bulk-edit.phps line 141

if ($data["params"]["bulk"] == "move-down")
{
$id = $data["params"]["data"];

// here you can code your logic to do bulk processing
$g->execute_query("CALL movedown($id)");
die;
}
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

3 + 16 =

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?