XSteps, PI Sheets, Electronic Work Instructions
Wednesday, February 17, 2010 Stylesheet Tip: Avoid Scrolling of Table Column Headers
VN:F [1.9.17_1161]
Rating: 5.0/5 (4 votes cast)

When a table in the PI Sheet has more than 10 lines the scrolling of the table content is activated. When you scroll down the headers of the table columns get lost because they are also in the scrolling area. This is of course not very user friendly. In the following section I describe a simple stylesheet enhancement that solves this problem. The initial idea came from one of SAP’s customers (thank you Christoph!) and I have added the fix for dropdown lists.

The first location is in the general template for tables called ‘builderrepeat’ (<xsl:template name=”builderrepeat”>) of your XSL. Scroll down to the comment ‘<!– Table body –>’ and insert the following code:

<!-- Table body -->
<DIV ID="_bfw_tab_scroll_" ...
 <TABLE ID="_bfw_tab_body_" ...
  <THEAD>
   <TR ID="_bfw_tab_text_">
   <!-- ### MX_010: Insert Start   ########################################### -->
     <xsl:attribute name="style">position:relative;top:expression(this.offsetParent.scrollTop)</xsl:attribute>
   <!-- ### MX_010: Insert End     ########################################### -->

Please do not split the red coding part into several lines!

This already will probably work for most use cases. However if you are using dropdown lists in your table then the top-most dropdown list element would be scrolled into the title. To avoid this I have added  the following code to hide that element as soon as it reaches the title area:

<xsl:template match="INPUT[ancestor::INSTRUCTION[./@type='repeat' or ./@group]]" mode="repeat">
  <TD CLASS="TABFIELD" ID="_bfw_component_" _BFW_TYPE_="bfwInput">
    <xsl:attribute name="_BFW_KEY_">
      <xsl:value-of select="./@id" />
    </xsl:attribute>
    <xsl:choose>
      <xsl:when test="./HELPVALUE">
        <SPAN ID="_SELECT_">
        <!-- ### MX_010: Replace Delete ########################################### old code below...
          <SELECT STYLE="width:100%" ID="_bfw_field_" CLASS="TIFDINACTIVE" TABINDEX="-1"
          SIZE="1" _BFW_CSS_ACTIVE_="TIFDACTIVE" _BFW_CSS_INACTIVE_="TIFDINACTIVE"
         _BFW_CSS_DEFAULT_="TIFDDEFAULT" _BFW_CSS_ERROR_="TIFDERROR" _BFW_CSS_DISABLED_="TIFDDISABLED">
             ### MX_010: Replace Insert ###########################################
             ... to avoid that select elements are scrolling into the column title -->
          <SELECT STYLE="width:100%; visibility:expression(MX_Hide_Select(this))" ID="_bfw_field_"
            CLASS="TIFDINACTIVE" TABINDEX="-1" SIZE="1" _BFW_CSS_ACTIVE_="TIFDACTIVE"
            _BFW_CSS_INACTIVE_="TIFDINACTIVE" _BFW_CSS_DEFAULT_="TIFDDEFAULT" _BFW_CSS_ERROR_="TIFDERROR"
            _BFW_CSS_DISABLED_="TIFDDISABLED">
       <!-- ### MX_010: Replace End ########################################### -->
    <xsl:for-each select="./HELPVALUE">

As you can see there is also some javascript code involved:

//------------------------------------------------------------------------------------
// MX_010: Table column headers stay at the top
//------------------------------------------------------------------------------------
// This function hides SELECT objects
function MX_Hide_Select(obj) {
 div_scrollTop  = obj.offsetParent.offsetParent.offsetParent.scrollTop;
 line_offsetTop = obj.offsetParent.offsetTop;
 obj_offsetTop  = obj.offsetTop;
  head_height    = obj.offsetParent.offsetParent.firstChild.offsetHeight;
 if (div_scrollTop + head_height > line_offsetTop + obj_offsetTop) {
  return 'hidden';
 } else {
  return 'visible';
 }
}

You have to provide that code in a separate JS file and of course you need to link this JS file in the HTML header definitions in your XSL:

<SCRIPT LANGUAGE=”JavaScript” SRC=”SAPR3-WR-Z_YOUR_JS_FILE.JS”/>

Some remarks:

Using expressions for CSS styles is only possible in Internet Explorer. But since the PI Sheets depends on IE this is not a problem. Due to the constant running of Javascript code these expressions might slow down your performance if you use them a lot. So please use with care!

Stylesheet Tip: Avoid Scrolling of Table Column Headers, 5.0 out of 5 based on 4 ratings
Please rate the article:
VN:F [1.9.17_1161]
Rating: 5.0/5 (4 votes cast)
1 Comment Create new comment
  1. Suraj Sadotra's Gravatar Suraj Sadotra
    10.May.2010 at 10:49 | Permalink

    Hello Arne,

    It works perfect.

    I have one more requirement, where in I have to place cursor on first input field, currently system places it on on the commandbar.

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Cockpit Posts   Comments
Visitors: 37295, Today: 2, Per Day: 44
Register / Login /

News

Next Session:
July 4th 2012, 3pm
Check with your time zone

Poll

Is the Apple iPad suited for manufacturing?

(View Results)

Loading ... Loading ...

Archives

Calendar

February 2010
M T W T F S S
« Jan   Mar »
1234567
891011121314
15161718192021
22232425262728