bulkedit-use

Questionsbulkedit-use
Georges asked 2 months ago

Hi, I want to use \’Bulkedit\’ but your demo code isn\’t very usefull for example, what means $grid[\”bulkedit_options\”][\”position\”] = 4; // js callback for bulk edit form dialog ??? how to manage code event when bulkedit is used? Thanks   Regards Georges

3 Answers
Abu Ghufran Staff answered 2 months ago

To enable bulk edit, set bulkedit -> true in set_actions.

"bulkedit"=>true,

To use on_update callback event with bulkedit, you can:

// event handler to manage Bulk Operations
$e["on_update"] = array("update_data","",true);
$g->set_events($e);

function update_data($data)
{
	global $g;
	$selected_ids = $data["id"];
	if (count(explode(",",$selected_ids)) > 1)
	{
		$g->execute_query("UPDATE .... WHERE id IN ($selected_ids)");	
	}
}

// Following sets the bulk edit icon position in toolbar

$grid["bulkedit_options"]["position"] = 4;
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Georges answered 2 months ago

Thanks Abu!

is it possible to read,one by one, Ids in $selected_ids ?  and if possible, how ?

Abu Ghufran Staff answered 2 months ago

You can use foreach loop after exploding the csv string with comma, see following callback …

function update_data($data) 
{ 
  global $g; 
  $selected_ids = $data["id"]; 
  $ids = explode(",",$selected_ids); 
  // check if more than 1 ids are selected 
  if (count($ids) > 1) 
  { 
    foreach($ids as $i) 
    { 
      $g->execute_query("UPDATE .... WHERE id = '$i'"); 
    }
  }
}

 

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

18 + 19 =

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?