All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
  Print view

howto make o2mchild datagrid hdr floating while scrolldown
Author Message
PostPosted: Fri Sep 18, 2015 3:50 pm 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 311
Location: Mumbai, India
howto make o2mchild datagrid hdr floating while scrolldown?
---------------------------------------------------------------------
the case in point : in classic o2m parent child node - child typically has 30/40/50 even 100 rows and there is a need to show all rows in one page ie avoid pagination. This is possible by overiding modifydatagrid() function. The problem is when user scrolls down to 30th, 40th,... 100th row the grid-column-header scrolls out of page from the top and what data is what column track is lost. So user needs floating header --- any clues how to do it?

Anyway as a stop-gap arrangement i repeat the grid-header at the bottom after numeric column totals (AF_TOTAL attributes). So i made following changes in
atk/datagrid/class.atkdglist.inc
and
atk/themes/steelblue/templates/recordlist.tpl

May be it is of use to others for other reasons.

atk/datagrid/class.atkdglist.inc->function getRecordlistData($recordset, $actions, $suppressList="") -> bottom before return statement - $headerBottoom new variable defined and used in the template like this
Code:
     /*
     Thu.17.Sep.2015 :
     recordlist grid if > say 20 rows then user has to scroll down and looses header ie which column is what
     if so repeat grid-caption header again at bottom search $headerBottoom in atkdglist.inc
     see usage in recordlist.tpl
     config.inc.php
     $config_recordlist_header_repeat_at_bottom_reccnt = 5; //show/repeat grid-header at bottom if rows>5

     */

     //$totalcols = $headercols;
    //$vorientation = atkconfig('recordlist_header_repeat_at_bottom_reccnt', $theme->getAttribute("recordlist_header_repeat_at_bottom_reccnt"));
    $recordlist_header_repeat_at_bottom_reccnt = atkconfig('recordlist_header_repeat_at_bottom_reccnt', 20);
    $reccnt = count($records);
     atk_var_dump($reccnt, '<<>>reccnt');
     atk_var_dump($recordlist_header_repeat_at_bottom_reccnt, '<<>>recordlist_header_repeat_at_bottom_reccnt');
    $headerBottoom =  "";
    if ($reccnt > $recordlist_header_repeat_at_bottom_reccnt)
    {
     //$headerBottoom =  $headercols; //works
    }
    $module = $grid->getNode()->m_module;
    $nodetype = $grid->getNode()->m_type;
    //atk_var_dump($module, '>>>module in atkgridlist');
    //atk_var_dump($nodetype, '>>>nodetype in atkgridlist');
    if (($module == 'requests' and $nodetype == 'request_alloc')
        // or ($module == 'skills' and $nodetype == 'sw_skills_alloc')
        // or ($module == 'skills' and $nodetype == 'deli_skills_alloc')
         //or ($module == 'requests' and $nodetype == 'request_hdr_new')
         //or ($module == 'shift' and $nodetype == 'shift_date_hdr')
         //or ($module == 'shift' and $nodetype == 'shift_date_alloc')
     )
    {
     $headerBottoom =  $headercols;
    }



    $recordListData = array("vorientation"=>$vorientation,
                            "rows"=>$records,
                            "header"=>$headercols,
                            "search"=>$searchcols,
                            "sort"=>$sortcols,
                            "total"=>$totalcols,
                            "searchstart"=>$searchstart,
                            "searchend"=>$searchend,
                            "sortstart"=>$sortstart,
                            "sortend"=>$sortend,
                            "liststart"=>$liststart,
                            "listend"=>$listend,
                            "listid"=>$listName,
                            "mra"=>$mra,
                            "mraTop"=>$mraTop,
                            "headerBottoom"=>$headerBottoom,
                            "editing"=>$this->getGrid()->isEditing());

    return $recordListData;
  }   //  private function getRecordlistData($recordset, $actions, $suppressList="")




atk/themes/steelblue/templates/recordlist.tpl see how $headerBottoom used to repeat grid-header at the bottom of the grid
Code:
{if isset($formstart)}{$formstart}{/if}
<table cellspacing="0" cellpadding="0" class="recordListContainer">
  <!-- dbg Fri.16.May.2014 MRA copied from bottom to here ref $mraTop needs to be set in datagrid/class.atkdglist.inc -->
  {if $mraTop!=""}
  <!-- multirecord actions -->
   <tr>
     <td valign="top" style="padding-top: 0px">
       {if $editing}
         {$mraTop}
       {else}
         <table border="0" cellspacing="0" cellpadding="0">
           <tr>
             <!-- dbg Thu.22.May.2014 minus.gif instead of arrow.gif since atkdglist De/Select Suppressed -->
             <td valign="top" style="padding-top: 0px; padding-left: 2px"><img src="{$atkroot}atk/images/minus.gif" border="0"></td>
             <td style="padding-top: 6px; padding-left: 5px">
               {$mraTop}
             </td>
           </tr>
         </table>
       {/if}
     </td>
   </tr>
  {/if}
  <tr>
    <td>
        <table id="{$listid}" class="recordList" cellpadding="0" cellspacing="0">
            <!-- header -->
            <tr>
              {section name=headerloop loop=$header}
                <th valign="{$vorientation}" {if isset($header[headerloop].htmlattributes)}{$header[headerloop].htmlattributes}{/if}
                 {if $smarty.section.headerloop.index===0}class="recordListThFirst"{else}class="recordListTh"{/if}>
                  {if $header[headerloop].content != ""}{$header[headerloop].content}{else}&nbsp;{/if}
                </th>
              {/section}
            </tr>

            {if count($sort)}
              <!-- sort row -->
              <tr>
              {$sortstart}
              {foreach from=$sort item=col}
                  <th valign="{$vorientation}" {if isset($col.htmlattributes)}{$col.htmlattributes}{/if}>
                    {if $col.content != ""}{$col.content}{else}&nbsp;{/if}
                  </th>
              {/foreach}
              {$sortend}
              </tr>
            {/if}

            {if count($search)}
              <!-- search row -->
              <tr>
              {$searchstart}
              {foreach from=$search item=col}
                  <th class="recordListSearch" valign="{$vorientation}" {if isset($col.htmlattributes)}{$col.htmlattributes}{/if}>
                    {if $col.content != ""}{$col.content}{else}&nbsp;{/if}
                  </th>
              {/foreach}
              {$searchend}
              </tr>
            {/if}

            <!-- records --> <!-- dbg Wed.23.Jan.2013 below onclick changed to ondblclick  = dblclick will open record in admin/list  Also ['select', 'edit', 'view'] edit removed otherwise default edit -->
            <!-- onclick="selectrow(this, '{$listid}', {$row.rownum})"> original. dbg New is below DblClickLine also below 'edit' removed from ['select',  'view'] -->
            {$liststart}
            {foreach from=$rows item=row}
              <tr id="{$row.id}" class="{$row.class}" {if $row.background!=""}style="background-color:{$row.background}" {/if}
                   onmouseover="highlightrow(this, '{$row.highlight}')"
                   onmouseout="resetrow(this)"
                   ondblclick="selectrow(this, '{$listid}', {$row.rownum})">
               {section name=colloop loop=$row.cols}
               <{if $row.type == "subtotal"}th{else}td{/if}
                    class="{if $smarty.section.colloop.index===0}recordListTdFirst{else}recordListTd{/if}{if $row.cols[colloop].type == "data"} clickable{/if}"
                    valign="{$vorientation}"  {if isset($row.cols[colloop].htmlattributes)}{$row.cols[colloop].htmlattributes}{/if}
                    {if $row.cols[colloop].type == "data"} onclick="rl_try('{$listid}', event, {$row.rownum}, ['select',  'view'], false);"{/if}>
                  {if $row.cols[colloop].content != ""}{$row.cols[colloop].content}{else}&nbsp;{/if}
                </{if $row.type == "subtotal"}th{else}td{/if}>
              {/section}
            </tr>
            {/foreach}
            {$listend}

            {if count($total)}
            <!-- totals row -->
              <tr>
              {foreach from=$total item=col}
                  <th valign="{$vorientation}" {if isset($col.htmlattributes)}{$col.htmlattributes}{/if}>
                    {if $col.content != ""}{$col.content}{else}&nbsp;{/if}
                  </th>
              {/foreach}
              </tr>
            {/if}
            <!-- Thu.17.Sep.2015  repeat grid-caption header again at bottom search headerBottoom in atkdglist.inc -->
            <!-- also see config.inc.php -> $config_recordlist_header_repeat_at_bottom_reccnt = 5; //show/repeat grid-header at bottom if rows>5  -->

            <tr>
              {section name=headerloopBottom loop=$headerBottoom}
                <th valign="{$vorientation}" {if isset($headerBottoom[headerloopBottom].htmlattributes)}{$headerBottoom[headerloopBottom].htmlattributes}{/if}
                 {if $smarty.section.headerloopBottom.index===0}class="recordListThFirst"{else}class="recordListTh"{/if}>
                  {if $headerBottoom[headerloopBottom].content != ""}{$headerBottoom[headerloopBottom].content}{else}&nbsp;{/if}
                </th>
              {/section}
            </tr>

      </table>
    </td>
  </tr>
  {if $mra!=""}
  <!-- multirecord actions -->
   <tr>
     <td valign="top" style="padding-top: 0px">
       {if $editing}
         {$mra}
       {else}
         <table border="0" cellspacing="0" cellpadding="0">
           <tr>
             <td valign="top" style="padding-top: 0px; padding-left: 2px"><img src="{$atkroot}atk/images/arrow.gif" border="0"></td>
             <td style="padding-top: 6px; padding-left: 5px">
               {$mra}
             </td>
           </tr>
         </table>
       {/if}
     </td>
   </tr>
  {/if}
</table>
{if isset($formend)}{$formend}{/if}


modifydatagrid() override in the o2m node to show all child rows in one page - remove paginations code
Code:
     //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
   public function modifyDataGrid(atkDataGrid $grid, $mode)
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//
   {
     atk_var_dump( $grid->getDefaultActions());

     // Change the default limit on a node (Show less or more items on a single page)
     $limit = $grid->getLimit();
     $count = $grid->getCount();
     $grid->setDefaultLimit($count);
     // Change the default limit on a node (Show less or more items on a single page)
     //$grid->setDefaultLimit(123);


     // Remove the record count summary in the bottom right of the datagrid
     $grid->removeComponent("summary");
     $grid->removeComponent("limit");
     $grid->removeComponent("paginator");
    //$this->addComponent('summary', 'atk.datagrid.atkdgsummary');
    //$this->addComponent('limit', 'atk.datagrid.atkdglimit');
    //$this->addComponent('norecordsfound', 'atk.datagrid.atkdgnorecordsfound');
    //$this->addComponent('paginator', 'atk.datagrid.atkdgpaginator');

   }


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group