Move Multirow controls? [SOLVED]

Talk about implementation of multirow operations

Moderators: ne_moj, zewa

bradkb
Newbie
Newbie
Posts: 9
Joined: Jun 9th, '09, 18:46

Move Multirow controls? [SOLVED]

Postby bradkb » Mar 27th, '10, 23:15

Hey guys

We have wrote a custom multirow operation for updating multiple records, our default page size is 250, but having to scroll to the bottom when the majority will be select all and perform operation, can we move this to the top of the table? if so how?

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

Re: Move Multirow controls?

Postby administrator » Mar 28th, '10, 08:30

Look on DrawMultiRowBar() method

bradkb
Newbie
Newbie
Posts: 9
Joined: Jun 9th, '09, 18:46

Re: Move Multirow controls?

Postby bradkb » Mar 31st, '10, 10:20

Could you expand on that, had a look and I had a quick play with not very good results.

bradkb
Newbie
Newbie
Posts: 9
Joined: Jun 9th, '09, 18:46

Re: Move Multirow controls?

Postby bradkb » Mar 31st, '10, 11:39

Not to worry - sorted it.

Tried to use the existing function, but ended up with 1 multirow operation at the top and two at the bottom!

In the end, copied the function, modified to suit and called it

DrawMultiRowTop()

Works great.!

kazak.71
Junior
Junior
Posts: 23
Joined: Jul 22nd, '09, 09:24

Re: Move Multirow controls? [SOLVED]

Postby kazak.71 » Apr 27th, '10, 19:57

bradkb,
would you share your DrawMultiRowTop method? pls!!!

bradkb
Newbie
Newbie
Posts: 9
Joined: Jun 9th, '09, 18:46

Re: Move Multirow controls? [SOLVED]

Postby bradkb » May 13th, '10, 19:07

Our problem was we wanted the multirow operations at the top and bottom of the grid, so users did not have to scroll to perform functions.

So, like suggested I searched the datagrid class for DrawMultiRowBar, found the function and copied it, but called it DrawMultiRowBarTop

Then found the function to draw the top section -

protected function DrawFiltering()

At the bottom of this function is the closure of the tables,

Code: Select all




            }
            echo "</td></tr></table>\n";
        }           
 
    }


so we inserted this

Code: Select all


        $this->DrawMultiRowBarTop();

so the code looks like

Code: Select all


            }
            echo "</td></tr></table>\n";
        }           
        $this->DrawMultiRowBarTop();
    }




This is our top multirow function code, we did change a few parts such as the arrow etc to match our requirement.

Code: Select all

    protected function DrawMultiRowBarTop(){
                    $horizontal_align = ($this->tblAlign[$this->mode] == "center") ? "margin-left: auto; margin-right: auto;" : ""; 
       
                    // This is where multirow needs to go Brad!
     
         if(($this->isMultirowAllowed)){
            echo $this->ScriptOpen();
            echo "function ".$this->uniquePrefix."verifySelected(param, button_type, flag_name, flag_value){
                if(confirm('".$this->lang['alert_perform_operation']."')){
                    selected_rows = '&".$this->uniquePrefix."rid=';
                    selected_rows_ids = '';
                    found = 0;
                    for(i=".$this->rowLower."; i < ".$this->rowUpper."; i++){
                        if(document.getElementById(\"".$this->uniquePrefix."checkbox_\"+i) && document.getElementById(\"".$this->uniquePrefix."checkbox_\"+i).checked == true){
                            if(found == 1){ selected_rows_ids += '-'; }
                            selected_rows_ids += document.getElementById(\"".$this->uniquePrefix."checkbox_\"+i).value;
                            found = 1;
                        }
                    }
                    if(found){
                        document_location_href = param+selected_rows+selected_rows_ids;
                        if(flag_name != ''){                           
                            found = (document_location_href.indexOf(flag_name) != -1);
                            if(!found){
                                document_location_href += '&'+flag_name+'='+flag_value;
                            }
                        }\n";
                        if($this->ajaxEnabled) echo "document.location.href = document_location_href;";
                        else echo "document.location.href = document_location_href.replace(/&amp;/g, '&');";
                        echo "
                    }else{
                        alert('".$this->lang['alert_select_row']."');
                        return false;
                    }
                }
            };           
            function ".$this->uniquePrefix."setCheckboxes(check){
                if(check){
                    for(i=".$this->rowLower."; i < ".$this->rowUpper."; i++){
                        if(document.getElementById('".$this->uniquePrefix."checkbox_'+i)){
                            document.getElementById('".$this->uniquePrefix."checkbox_'+i).checked = true;
                            document.getElementById('".$this->uniquePrefix."row_'+i).style.background = '".$this->rowColor[5]."';                                               
                        }
                    }
                }else{
                    for(i=".$this->rowLower."; i < ".$this->rowUpper."; i++){
                        if(document.getElementById('".$this->uniquePrefix."checkbox_'+i)){
                            document.getElementById('".$this->uniquePrefix."checkbox_'+i).checked = false;
                            if((i % 2) == 0) row_color_back = '".$this->rowColor[0]."';
                            else row_color_back = '".$this->rowColor[1]."';
                            document.getElementById('".$this->uniquePrefix."row_'+i).style.background = row_color_back;                       
                        }
                    }               
                }
            }";
            echo $this->ScriptClose();
            echo "\n<table dir='".$this->direction."' border='0' style='".$horizontal_align." padding-top:0px; margin-top:0px;' width='".$this->tblWidth[$this->mode]."'>";
            echo "\n<tr>"; 
            echo "\n<td align='".(($this->direction == "ltr") ? "left" : "right")."'>"; ?><div class="logouttext"><a href="patient-search.php"><img src="../css/images/search_unhide_r.jpg" border="0" alt="Search for a patient"></a></div>  <?
            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++;
                        }                       
                        if($count > 0){
                            echo "<img style='padding:0px; margin:0px; border:0px;' src='".$this->directory."styles/".$this->cssClass."/images/arrow_ttr.png' alt='".$this->lang['with_selected']."' title='' />";
                                if(!$this->isPrinting){
                                    echo "<td class='upper'><a class='".$this->cssClass."_dg_a' href='javascript:void(0);' onClick='".$this->uniquePrefix."setCheckboxes(true); return false;'>".$this->lang['check_all']."</a> / <a class='".$this->cssClass."_dg_a' href='javascript:void(0);' onClick='".$this->uniquePrefix."setCheckboxes(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></td>";                                   
                                }
                            echo "<label class='".$this->cssClass."_dg_label' style='padding-left:4px;padding-right:4px;'><i>".$this->lang['with_selected'].":</i></label> </td>
                                  <td style='padding-top:0px;' align='".(($this->direction == "ltr") ? "left" : "right")."' valign='middle'>";   
                            foreach($this->arrMultirowOperations as $key => $val){
                                if($this->arrMultirowOperations[$key]['view']){
                                    echo "<img src='".$this->directory."images/spacer.gif' width='7px' 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);
                                    $this->DrawModeButton($key, $curr_url, $tooltip, $tooltip, $image, "\"return ".$this->uniquePrefix."verifySelected('$curr_url', '$key', '$flag_name', '$flag_value');\"", false, "", "image");
                                }
                            }
                        }                             
            echo "\n</td>\n</tr>\n</table>";   
            echo "\n</td>\n</tr>\n</table>";   
        }
       
       
       
       
       
        /// end of top multirow function
       
    }



Hope this helps


Return to “Settings: multirow operations”