HOW TO define multi-row operations?

Talk and info about common issues

Moderator: alexandrleonenko

administrator
Site Admin
Site Admin
Posts: 6169
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO define multi-row operations?

Postby administrator » May 31st, '10, 19:05

To define multi-row operations, you have to perform following:

1. Allow multi-row operations:

Code: Select all

$multirow_option = true;
$dgrid->AllowMultirowOperations($multirow_option);


2. Define which operations will be available:

Code: Select all

$multirow_operations = array(
   "edit"    => array("view"=>true),
   "details" => array("view"=>true),
   "clone"   => array("view"=>false),
   "delete"  => array("view"=>true)
);
$dgrid->SetMultirowOperations($multirow_operations);


You may define your own operation, by using:

Code: Select all

"my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")

HINT: don't use the same names for operation name and flag name -they must be different.

where "flag_name" - variable, that will be used for detecting your operation and "flag_value" the value of this variable.
For example:

Code: Select all

"my_operation_name" => array("view"=>true, "flag_name"=>"move", "flag_value"=>"yes", "tooltip"=>"Do something with selected", "image"=>"image.gif")


In this case, you can detect that cloning multi-row operation was performed by retrieving from URL.
Place this code in your file before creating and calling of datagrig object.

Code: Select all

// If you define  $postback_method = "post"; use  $_POST to retrieve these parameters
// put attention that "prefix_" is a real prefix of your datagrid
$operation_move = isset($_GET['move']) ? $_GET['move'] : "";
$rids = isset($_GET['prefix_rid']) ? $_GET['prefix_rid'] : "";

if($operation_move == "yes"){
   $rids_parts = explode("-", $rids); // array of IDs
   foreach($rids_parts as $rid){
       ...your code here for each RID ...
   }
   if(success){
       ... success message here...
   }else{
       ... error message here...
   }
}


$dgrid->SetPostBackMethod($postback_method);

Return to “ApPHP DataGrid {HOW TO}”