Javascript confirmation of multirow custom operation?

Talk about implementation of multirow operations

Moderators: ne_moj, zewa

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Javascript confirmation of multirow custom operation?

Postby nkd » Apr 17th, '11, 01:28

I have a custom operation added to the $multirow_operations array and I would like to have a javascript confirmation message asking if you want to proceed with that operation (like when you try to delete).

How can I tell datagrid to show a confirmation message? if possible I would like to have different messages for each custom operation.

Thank you.

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

Re: Javascript confirmation of multirow custom operation?

Postby administrator » Apr 17th, '11, 09:47

Currently it's not possible - you may change datagrid code to switch between actions.
We'll try to improve this feature in the next version.

lambro
Master
Master
Posts: 102
Joined: Sep 13th, '10, 14:31
Location: Metz, France

Time for a bit of code

Postby lambro » Apr 17th, '11, 11:01

OOook, this thread seems like a good time to try and implement some changes in the multirow operations :

First, everything displayed here is fully functionnal and can be tried at : Cheesy example :
http://thomas.ambrosini.free.fr/Apphp/dg_example.php
I use Datagrid 6.4.1, and the POST SetPostBackMethod.

We're going to twitch the datagrid.class.php file a little, just a bit.
It is currently quite efficient, but it still need to be upgraded by the apphp developpement team. When you read and test this Admin, you'll understand.

Here we go :
01) create your regular datagrid file. In it, search for the line :

Code: Select all

$dgrid->SetPostBackMethod($postback_method);


There, input the following code to retrieve your multirow data :

Code: Select all

switch ( $postback_method ){
      case "ajax":
      $mode = (isset($_REQUEST['cheesemode'])&& $_REQUEST['cheesemode']!='') ? $_REQUEST['cheesemode'] : "";
      $rid = (isset($_REQUEST['cheeserid'])&& $_REQUEST['cheeserid']!='') ? $_REQUEST['cheeserid'] : "";
      break;
      case "get" :
      $mode = (isset($_GET['cheesemode'])&& $_GET['cheesemode']!='') ? $_GET['cheesemode'] : "";
      $rid = (isset($_GET['cheeserid'])&& $_GET['cheeserid']!='') ? $_GET['cheeserid'] : "";
      break;
      case "post":
      $mode = (isset($_POST['cheesemode'])&& $_POST['cheesemode']!='') ? $_POST['cheesemode'] : "";
      $rid = (isset($_POST['cheeserid'])&& $_POST['cheeserid']!='') ? $_POST['cheeserid'] : "";
      $returnpage = (isset($_POST['cheesep'])&& $_POST['cheesep']!='') ? $_POST['cheesep'] : "1";
      $valDDlMulti = (isset($_POST['opTDdl'])&& $_POST['opTDdl']!='') ? $_POST['opTDdl'] : "1";
      break;
      }

Pay extra attention to the $returnpage and $valDDlMulti values, we'll get back to them later.

02) Set your regular multirow options :

Code: Select all

##  *** allow multirow operations
    $multirow_option = ($_SESSION['user_type'] >= 3)? true:false;
     $dgrid->AllowMultirowOperations($multirow_option);
     $multirow_operations = array(
      "clone" => array("view"=>true),
        "edit"    => array("view"=>true),
        "details" => array("view"=>true),
        "delete"  => array("view"=>false));
   if ($_SESSION['user_type']==100){
   $ARtestVal = array ("0"=>"0","1"=>"1","2"=>"2","3"=>"3");
      $multirow_operations["ActionNtoA"]=  array("view"=>true, "flag_name"=>"opN2A", "flag_value"=>"O", "tooltip"=>"Activation", "image"=>"NtoA.gif", "typaffich"=>"", "confirm"=>"false");
      $multirow_operations["ActionAtoN"]=  array("view"=>true, "flag_name"=>"opA2N", "flag_value"=>"N", "tooltip"=>"Désactivation", "image"=>"AtoN.gif", "typaffich"=>"", "confirm"=>"false");
      $multirow_operations["SetStock"]  =  array("view"=>true, "flag_name"=>"opSs",  "flag_value"=>"I", "tooltip"=>"Réinitialisation stock", "image"=>"SetStock.gif", "typaffich"=>"", "confirm"=>"true");
      $multirow_operations["ActionDDl"] =  array("view"=>true, "flag_name"=>"opTDdl","flag_value"=>"Test", "tooltip"=>"Test", "image"=>"","typaffich"=>"dropdownlist", "confirm"=>"false", "table"=>"cheese",
      "field"=>"stock", "field_view"=>"Stock", "disabled"=>"", "show_count"=>false,"source"=>$ARtestVal, "multiple"=>"", "multiple_size"=>"2");
      $multirow_operations["ActionDDl2"] =  array("view"=>true, "flag_name"=>"opTDdl","flag_value"=>"Test2", "tooltip"=>"Test", "image"=>"","typaffich"=>"dropdownlist", "confirm"=>"false", "table"=>"cheese",
      "field"=>"stock", "field_view"=>"Stock", "disabled"=>"", "show_count"=>false, "source"=>"self", "multiple"=>"", "multiple_size"=>"2");}
   
    $dgrid->SetMultirowOperations($multirow_operations); 

This line here : $multirow_option = ($_SESSION['user_type'] >= 3)? true:false; Enables me to set multirow options in accordance with a user level.
Thus, the code "if ($_SESSION['user_type']==100){" enables me to add extra options. If the regular options definitions array only ask for "view", the custom operations need more :
Currently, you should have something like :

Code: Select all

array("view"=>true, "flag_name"=>"opN2A", "flag_value"=>"O", "tooltip"=>"Activation", "image"=>"NtoA.gif");

My suggestion at this point on (and yes administrator, you know where we're going with this :D )

Code: Select all

"typaffich"=>"", "confirm"=>"false");

For now nkd, this should be sufficient for you. Simply set the "confirm" option to blank.

3) At the bottom of your datagrid file, after binding your datagrid and before flushing the object, retrieve your multirow settings and do your operation.
In my example it is like this :

Code: Select all

$dgrid->Bind();
   // Gestion NtoA
   if ($mode =="ActionNtoA" && $rid != ""){
      $rids_parts = explode("-", $rid);
      foreach ($rids_parts as $key =>$val){ SetoA($val);}
      gobacktopage($returnpage);
   }
   // Gestion AtoN
   if ($mode =="ActionAtoN" && $rid != ""){
      $rids_parts = explode("-", $rid);
      foreach ($rids_parts as $key =>$val){ SetoN($val);}
      gobacktopage($returnpage);
   }
   // Gestion SetStock
   if ($mode =="SetStock" && $rid != ""){
      $rids_parts = explode("-", $rid);
      foreach ($rids_parts as $key =>$val){ SetStocK($val);}
      gobacktopage($returnpage);
   }
   // Gestion ActionDDl
   if ($mode =="ActionDDl" && $rid != "" && $valDDlMulti != ""){
      $rids_parts = explode("-", $rid);
      foreach ($rids_parts as $key =>$val){SetStocKAllowval($val,$valDDlMulti);}
      gobacktopage($returnpage);
   }
   // Gestion ActionDDl2
   if ($mode =="ActionDDl2" && $rid != "" && $valDDlMulti != ""){
      $rids_parts = explode("-", $rid);
      foreach ($rids_parts as $key =>$val){SetStocKAllowval($val,$valDDlMulti);}
      gobacktopage($returnpage);
   }
   ob_end_flush();

Let's focus on the first three operations and leave the dropdownlists for now.
The $mode value gets the $multirow_operations["__KEY NAME__"] while the $rid corresponds to the array of selected rows (thanks apphp for datagrid pro. I mean, really. Thank you. Again)
The various functions I use ( "SetoA", "SetStock") are call to the database and update operations :
In my example:
Image sets "actif" to O, without confirmation.
Image sets "actif" to N, without confirmation.
Image sets "stock" to 0 value, with confirmation.
The two dropdownlists operation update the stock at the pre selectionned value. It is posted and retrieved with the $valDDlMulti variable.

the gobacktopage() function simply writes a javascript line that does a postwith() to redisplay the results. One day I'll switch to Ajax method...
It uses the $returnpage variable.
More about postwith() can be found here : http://www.apphp.net/forum/viewtopic.php?f=26&t=2200


So, where is the confirm message ?

Let's take a look at the datagrid.class, open it, and find the following code around line 3865 :

Code: Select all

 protected function DrawMultiRowBar($r){
        $horizontal_align = ($this->tblAlign[$this->mode] == "center") ? "margin-left: auto; margin-right: auto;" : "";       
        if(($this->isMultirowAllowed) && ($r != $this->rowLower)){
            echo "\n<table dir='".$this->direction."' border='0' style='".$horizontal_align."' width='".$this->tblWidth[$this->mode]."'>";
            echo "\n<tr>";
            echo "\n<td align='".(($this->direction == "ltr") ? "left" : "right")."'>";
            echo "\n<table border='0'>
                  \n<tr>
                    <td align='".(($this->direction == "ltr") ? "left" : "right")."' valign='middle' class='dg_nowrap'>";
                        $count = 0;
                        foreach($this->arrMultirowOperations as $key => $val){
                            if($this->arrMultirowOperations[$key]['view']) $count++;
                        }                       
                        echo "<img style='padding:0px;margin:0px;border:0px;' src='".$this->directory."styles/".$this->cssClass."/images/arrow_ltr.png' width='38' height='22' alt='' title='' />";
                        if(!$this->isPrinting){
                            echo "<a class='".$this->cssClass."_dg_a' href='javascript:void(\"check=all\");' onclick='setCheckboxes(\"".$this->uniquePrefix."\", ".$this->rowLower.", ".$this->rowUpper.", \"".$this->rowColor[5]."\", \"".$this->rowColor[0]."\", \"".$this->rowColor[1]."\", true); return false;'>".$this->lang['check_all']."</a> / <a class='".$this->cssClass."_dg_a' href='javascript:void(\"uncheck=all\");' onclick='setCheckboxes(\"".$this->uniquePrefix."\", ".$this->rowLower.", ".$this->rowUpper.", \"".$this->rowColor[5]."\", \"".$this->rowColor[0]."\", \"".$this->rowColor[1]."\", false); return false;'>".$this->lang['uncheck_all']."</a>";
                        }else{
                            echo "<a class='".$this->cssClass."_dg_label'>".$this->lang['check_all']."</label> / <a class='".$this->cssClass."_dg_label'>".$this->lang['uncheck_all']."</label>";                                   
                        }
                        if($count > 0){
                            echo "<td align='".(($this->direction == "ltr") ? "left" : "right")."' valign='bottom'>
                                    <label class='".$this->cssClass."_dg_label' style='padding-left:10px;padding-right:0px;'><i>".$this->lang['with_selected'].":</i></label>
                                  </td>
                                  <td align='".(($this->direction == "ltr") ? "left" : "right")."' valign='bottom'".(($this->browserName != "MSIE")?" style='padding-bottom:3px;'":"").">";
                            foreach($this->arrMultirowOperations as $key => $val){
                                if($this->arrMultirowOperations[$key]['view']){
                                    echo "<img src='".$this->directory."images/spacer.gif' width='6px' height='5px' alt='' />";
                                    $curr_url = $this->CombineUrl($key, "");
                                    $flag_name = isset($val['flag_name']) ? $val['flag_name'] : "";
                                    $flag_value = isset($val['flag_value']) ? $val['flag_value'] : "";
                                    $tooltip = isset($val['tooltip']) ? $val['tooltip'] : $this->lang[$key.'_selected'];
                                    $image = isset($val['image']) ? $val['image'] : $key.".gif" ;
                                    $this->SetUrlString($curr_url, "filtering", "sorting", "paging");
                                    $curr_url = str_replace("&", "&amp;", $curr_url);
                                    $http_get_vars_part = ($this->methodPostBack != "get") ? $this->GetHttpGetVars() : "";
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');\"", false, "", "image");
                                }
                            }
                        }                           
            echo "\n</td>\n</tr>\n</table>";
            echo "\n</td>\n</tr>\n</table>";
        }
    }

Focus on the "Foreach" loop, that's where I changed it like this :

Code: Select all

foreach($this->arrMultirowOperations as $key => $val){
                                if($this->arrMultirowOperations[$key]['view']){
                                    echo "<img src='".$this->directory."images/spacer.gif' width='6px' height='5px' alt='' />";
                                    $curr_url = $this->CombineUrl($key, "");
                                    $flag_name = isset($val['flag_name']) ? $val['flag_name'] : "";
                                    $flag_value = isset($val['flag_value']) ? $val['flag_value'] : "";
                                    $tooltip = isset($val['tooltip']) ? $val['tooltip'] : $this->lang[$key.'_selected'];
                                    $image = isset($val['image']) ? $val['image'] : $key.".gif" ; 
                           //New !
                           $typaffich = (isset($val['typaffich'])  &&  ($val['typaffich'] == 'dropdownlist' || $val['typaffich'] == 'Dropdownlist'))? "DropDownList" : "Button" ;
                           $needconfirm = (isset($val['confirm'])  &&   $val['confirm'] == 'true')? "if(confirm('".$this->lang['alert_perform_operation']."'))": "" ;
                           //
                                    $this->SetUrlString($curr_url, "filtering", "sorting", "paging");
                                    $curr_url = str_replace("&", "&amp;", $curr_url);
                                    $http_get_vars_part = ($this->methodPostBack != "get") ? $this->GetHttpGetVars() : "";
                           // New !
                              if (!isset($val['flag_name'])){
                                 $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');\"", false, "", "image");
                              } else {
                              /* Old version : specialized
                                 switch ($val['flag_name']){
                                 case "":
                                 case "opN2A":
                                 case "opA2N":
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"if(confirm('".$this->lang['alert_perform_operation']."')){return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');}\"", false, "", "image");
                                 break;
                                 case "opSs":
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"if( launchMyChoices()==true){if(confirm('".$this->lang['alert_perform_operation']."')){ return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');}}\"", false, "", "image");
                                 break;
                                 case "opTDdl":
                                    if(is_array($val["source"])){
                                    echo $this->DrawDropDownList($key, "", $val["source"],'', $val['field'], "", "", $val['disabled'], "onchange=\"if( launchMyChoices()==true){if(confirm('".$this->lang['alert_perform_operation']."')){ launchMyChoices(); return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', this.value, '$key', '$http_get_vars_part');}}\"", $val['multiple'], $val['multiple_size'],true);
                                    }/*else{
                                    $this->DrawDropDownList($val['flag_name'], $key, $this->GetEnumValues($this->tblName, $val['table']), trim($val['field']), $field_name, "", "", $disabled, $on_js_event, $enum_multiple, $fp_multiple_size);
                                    }
                                 break;
                                 default:
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');\"", false, "", "image");
                              */   
                              // Brand NEW ! Generic :
                                 if ($typaffich == 'DropDownList'){
                                    if(isset($val["source"]) && is_array($val["source"])){
                                       echo "Ok with Array".$this->DrawDropDownList($key, "", $val["source"],'', $val['field'], "", "", $val['disabled'], "onchange=\"".$needconfirm."{ return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', this.value, '$key', '$http_get_vars_part');}\"", $val['multiple'], $val['multiple_size'],true);
                                    } else {
                                       echo "Still need to twitch DB settings".$this->DrawDropDownList($key, "", $this->GetEnumValues($this->tblName, $val['table']), '',  $val['field'], "", "", $val['disabled'], "onchange=\"".$needconfirm."{ return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', this.value, '$key', '$http_get_vars_part');}\"", $val['multiple'], $val['multiple_size'],true);
                                    }
                                 } else {
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"".$needconfirm."{return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');}\"", false, "", "image");   
                                 }                           
                              }
                           }
                        }

The first "if" statement keeps the regular multirow options in the drawn bar.
The commented text is what I did at first, but it was not generic so I was not really pleased with it.Still, it was functional and you might need it, so... It can also show the fact THAT IT IS THE flag_name variable that matters for drowing elements.

The "$typaffich" value will draw a dropdownlist or display the image.
The "$needconfirm" value adds the javascript statement you were looking for, or a blank. For both dropdownlists and buttons.

@Administrator :
All there is to do is to finish the dropdownlist script when it is not filled by an array. And to polish the class a bit more like the apphp team would have. Think you can still do that before version 6.5.XX is released ? PLEAAAAAAASE ? :D

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

Re: Javascript confirmation of multirow custom operation?

Postby administrator » Apr 18th, '11, 08:48

We're planning to play with these messages here:
scripts/dg.js -> _dgJsVerifySelected()

lambro
Master
Master
Posts: 102
Joined: Sep 13th, '10, 14:31
Location: Metz, France

Re: Javascript confirmation of multirow custom operation?

Postby lambro » Apr 20th, '11, 06:49

All right then, I look forward to it.

In the mean time, I've corrected my code to have the dropdownlist filled by the db successfully and have added an extra legend text to those dropdownlists ("dropdownlistmessage"=>"__Your Message here__").

The parameters now read as such in the datagrid code template :

Code: Select all

$ARtestVal = array ("0"=>"0","1"=>"1","2"=>"2","3"=>"3");
$multirow_operations["ActionDDl"] =  array("view"=>true, "flag_name"=>"opTDdl","flag_value"=>"Test", "tooltip"=>"Test",
      "image"=>"","typaffich"=>"dropdownlist", "dropdownlistmessage"=>"Filled from array","confirm"=>"true", "table"=>"cheese",
      "field"=>"stock", "field_view"=>"Stock", "disabled"=>"", "show_count"=>false,"source"=>$ARtestVal, "multiple"=>"", "multiple_size"=>"2");
$multirow_operations["ActionDDl2"] =  array("view"=>true, "flag_name"=>"opTDdl","flag_value"=>"Test2", "tooltip"=>"Test",
      "image"=>"","typaffich"=>"dropdownlist", "dropdownlistmessage"=>"Filled from DB values","confirm"=>"false", "table"=>"cheese",
      "field"=>"stock", "field_view"=>"Stock", "disabled"=>"", "show_count"=>false, "source"=>"self", "multiple"=>"", "multiple_size"=>"2");}
   


The datagrid.class.php is edited this way :
Around line 3980, replace the whole foreach loop this way:

Code: Select all

foreach($this->arrMultirowOperations as $key => $val){
                                if($this->arrMultirowOperations[$key]['view']){
                                    echo "<img src='".$this->directory."images/spacer.gif' width='6px' height='5px' alt='' />";
                                    $curr_url = $this->CombineUrl($key, "");
                                    $flag_name = isset($val['flag_name']) ? $val['flag_name'] : "";
                                    $flag_value = isset($val['flag_value']) ? $val['flag_value'] : "";
                                    $tooltip = isset($val['tooltip']) ? $val['tooltip'] : $this->lang[$key.'_selected'];
                                    $image = isset($val['image']) ? $val['image'] : $key.".gif" ; 
                           //New !
                           $typaffich = (isset($val['typaffich'])  &&  ($val['typaffich'] == 'dropdownlist' || $val['typaffich'] == 'Dropdownlist'))? "DropDownList" : "Button" ;
                           $needconfirm = (isset($val['confirm'])  &&   $val['confirm'] == 'true')? "if(confirm('".$this->lang['alert_perform_operation']."'))": "" ;
                           $DdlMess = (isset($val['dropdownlistmessage'])  &&   $val['dropdownlistmessage'] != "")? $val['dropdownlistmessage']: "" ;
                           //
                                    $this->SetUrlString($curr_url, "filtering", "sorting", "paging");
                                    $curr_url = str_replace("&", "&amp;", $curr_url);
                                    $http_get_vars_part = ($this->methodPostBack != "get") ? $this->GetHttpGetVars() : "";
                           // New !
                              if (!isset($val['flag_name'])){
                                 $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');\"", false, "", "image");
                              } else {   
                              // Brand NEW ! Generic :
                                 if ($typaffich == 'DropDownList'){
                                    if(isset($val["source"]) && is_array($val["source"])){
                                       echo $DdlMess.$this->nbsp .$this->DrawDropDownList($key, "", $val["source"],$val['field'], $val["field"], "", "", $val['disabled'], "onchange=\"".$needconfirm."{ return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', this.value, '$key', '$http_get_vars_part');}\"", $val['multiple'], $val['multiple_size'],true);
                                    } else {                                       echo $DdlMess.$this->nbsp .$this->DrawDropDownList($key, "", $this->GetDistValMuDdl($this->tblName,$val['field']), trim($val['field']),  $val['field'], "", "", $val['disabled'], "onchange=\"".$needconfirm."{ return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', this.value, '$key', '$http_get_vars_part');}\"", $val['multiple'], $val['multiple_size'],true);
                                    }
                                 } else {
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"".$needconfirm."{return jsVerifySelected('".$this->uniquePrefix."', '".$this->rowLower."', '".$this->rowUpper."', '".$this->methodPostBack."', '".$this->GetRandomString(20)."', '$curr_url', '$key', '$flag_name', '$flag_value', '$key', '$http_get_vars_part');}\"", false, "", "image");   
                                 }                           
                              }
                           }
                        }


New function GetDistValMuDdl (put it where you want, preferably after GetEnumValues function):

Code: Select all

/**
     * NEW Get Distinct values for multirow dropdown
     */
    protected function GetDistValMuDdl( $table , $field ){
        $query = " SELECT DISTINCT $field FROM $table  ";
        $this->dbHandler->setFetchMode(DB_FETCHMODE_DEFAULT); 
        $result = $this->dbHandler->query($query);
        if($this->dbHandler->isError($result) != 1){
         for($i=0; $i < $result->numRows();$i++){
            $resArr = $result->fetchRow();
            $row[$i]= $resArr[$field];
         }
      }
      return $row;
   }

And a slight alteration to the function DrawDropDownlist : I put the selected="selected" option always on the firts choice.
All in all, it enables me to generate multi choiced operations at once. It can prove to be a tremendous time saver for many users and I think it could be useful in the future.


Return to “Settings: multirow operations”