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?
Move Multirow controls? [SOLVED]
Moderator: alexandrleonenko
-
- Site Admin
- Posts: 6016
- Joined: Jan 7th, '09, 23:18
- Contact:
Re: Move Multirow controls?
Look on DrawMultiRowBar() method
Re: Move Multirow controls?
Could you expand on that, had a look and I had a quick play with not very good results.
Re: Move Multirow controls?
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.!
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.!
Re: Move Multirow controls? [SOLVED]
bradkb,
would you share your DrawMultiRowTop method? pls!!!
would you share your DrawMultiRowTop method? pls!!!
Re: Move Multirow controls? [SOLVED]
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,
so we inserted this
so the code looks like
This is our top multirow function code, we did change a few parts such as the arrow etc to match our requirement.
Hope this helps
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(/&/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("&", "&", $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