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
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;
Thanks Abu!
is it possible to read,one by one, Ids in $selected_ids ? and if possible, how ?
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'");
}
}
}
Your Answer

