Bulk edit doesn't work. Only pass one row in array

QuestionsBulk edit doesn't work. Only pass one row in array
Juan Pedro Sánchez asked 4 years ago

$grid[“multiselect”] = true;
$grid[“bulkedit_options”][“afterShowForm”] = “function(){ }”;

$e[“on_update”] = array(“update_data”,””,true);
$g->set_events($e);

**************
function update_data($data)
{
$g = new jqgrid(); // temp grid object to execute sql

if ($data[“params”][“bulk”] == “change-pr-pc”)
{
$selected_ids = $data[“IdEncuentro”];
$str = $data[“params”][“data”];
phpgrid_error($data);

\\ result with some rows selected, only one IdEncuentro  —-  Array ( [IdEncuentro] => 17962 [params] => Array ( [bulk] => cambiar-pr-pc ) )

$g->execute_query(“UPDATE CompeticionesEncuentros SET PA_ENom = ‘PC’ WHERE IdEncuentro IN ($selected_ids) AND PA_ENom=’PR'”);

4 Answers
Abu Ghufran Staff answered 4 years ago

Hi,

I tried to regenerate this case but it’s work as expected.

You can put debugging like following and see response:

if ($data[“params”][“bulk”] == “change-pr-pc”)
{
        print_r($data);
        die;

}

and check ajax response in browser debugger:

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Juan Pedro answered 4 years ago

Hi Abu,

Sorry for the inconvenience, I think the error is a conflict with something I have in the following initial line. require_once($_SERVER[\”DOCUMENT_ROOT\”].\”/conf.php\”);

I don\’t understand how bulk edit works for me with its default function (all rows selected) and form edit, but not with specific update_data () function.

I have located the origin of the problem and I will see if I have any luck in solving it.

Thank you.

Juan Pedro answered 4 years ago

Hi Abu,

For your information, we have located the error.

In our config.php we had a security code to avoid attacks. Let’s protect certain variables and one of them is id (it only leaves a numeric value). We have noticed that in the header of the bulkedit call, our variable IdEncuentro does not pass but it is id by default, regardless of the name of the column in the grid (IdEncuentro).

When printing what we sent (phpgrid_error($data) or  print_r($data);, IdEncuentro always comes out and never id.

I just share the information in case it is useful.

Now we will see why it does not work for us with 2 grids on the same page, I suppose it will be something similar.

Abu Ghufran Staff answered 4 years ago

Thanks for updating, really appreciate it.

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

9 + 15 =

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?