{"id":670,"date":"2010-02-17T17:36:15","date_gmt":"2010-02-17T16:36:15","guid":{"rendered":"http:\/\/websha.de\/xstepcafe\/?p=670"},"modified":"2018-06-01T06:45:22","modified_gmt":"2018-06-01T04:45:22","slug":"stylesheet-tip-avoid-scrolling-of-table-column-headers","status":"publish","type":"post","link":"https:\/\/websha.de\/xstepcafe\/2010\/02\/17\/stylesheet-tip-avoid-scrolling-of-table-column-headers\/","title":{"rendered":"Stylesheet Tip: Avoid Scrolling of Table Column Headers"},"content":{"rendered":"<p>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&#8217;s customers (thank you Christoph!) and I have added\u00a0the fix for dropdown lists.<!--more--><\/p>\n<p>The first location is in the general template for tables called &#8216;builderrepeat&#8217; (&lt;xsl:template name=&#8221;builderrepeat&#8221;&gt;) of your XSL. Scroll down to the comment &#8216;&lt;!&#8211; Table body &#8211;&gt;&#8217; and insert the following code:<\/p>\n<blockquote>\n<pre><span style=\"color: #339966;\">&lt;!-- Table body --&gt;<\/span>\r\n&lt;DIV ID=\"_bfw_tab_scroll_\" ...\r\n\u00a0&lt;TABLE ID=\"_bfw_tab_body_\" ...\r\n\u00a0 &lt;THEAD&gt;\r\n\u00a0\u00a0 &lt;TR ID=\"_bfw_tab_text_\"&gt;\r\n<span style=\"color: #ff0000;\">\u00a0\u00a0 <span style=\"color: #339966;\">&lt;!-- ### MX_010: Insert Start\u00a0\u00a0 ########################################### --&gt;\r\n<\/span>\u00a0\u00a0\u00a0\u00a0 &lt;xsl:attribute name=\"style\"&gt;position:relative;top:expression(this.offsetParent.scrollTop)&lt;\/xsl:attribute&gt;\r\n\u00a0\u00a0 <span style=\"color: #339966;\">&lt;!-- ### MX_010: Insert End\u00a0\u00a0\u00a0\u00a0 ########################################### --&gt;<\/span><\/span><\/pre>\n<\/blockquote>\n<p>Please do not split the red coding part into several lines!<\/p>\n<p>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\u00a0 the following code to hide that element as soon as it reaches the title area:<\/p>\n<blockquote>\n<pre>&lt;xsl:template match=\"INPUT[ancestor::INSTRUCTION[.\/@type='repeat' or .\/@group]]\" mode=\"repeat\"&gt;\r\n  &lt;TD CLASS=\"TABFIELD\" ID=\"_bfw_component_\" _BFW_TYPE_=\"bfwInput\"&gt;\r\n    &lt;xsl:attribute name=\"_BFW_KEY_\"&gt;\r\n      &lt;xsl:value-of select=\".\/@id\" \/&gt;\r\n    &lt;\/xsl:attribute&gt;\r\n    &lt;xsl:choose&gt;\r\n      &lt;xsl:when test=\".\/HELPVALUE\"&gt;\r\n        &lt;SPAN ID=\"_SELECT_\"&gt;\r\n        <span style=\"color: #c0c0c0;\"><span style=\"color: #339966;\">&lt;!-- ### MX_010: Replace Delete ########################################### old code below...\r\n          &lt;SELECT STYLE=\"width:100%\" ID=\"_bfw_field_\" CLASS=\"TIFDINACTIVE\" TABINDEX=\"-1\"\r\n          SIZE=\"1\" _BFW_CSS_ACTIVE_=\"TIFDACTIVE\" _BFW_CSS_INACTIVE_=\"TIFDINACTIVE\"\r\n         _BFW_CSS_DEFAULT_=\"TIFDDEFAULT\" _BFW_CSS_ERROR_=\"TIFDERROR\" _BFW_CSS_DISABLED_=\"TIFDDISABLED\"&gt;\r\n             ### MX_010: Replace Insert ###########################################\r\n             ... to avoid that select elements are scrolling into the column title --&gt;<\/span>\r\n<\/span>          <span style=\"color: #ff0000;\">&lt;SELECT STYLE=\"width:100%; visibility:expression(MX_Hide_Select(this))\" ID=\"_bfw_field_\"\r\n            CLASS=\"TIFDINACTIVE\" TABINDEX=\"-1\" SIZE=\"1\" _BFW_CSS_ACTIVE_=\"TIFDACTIVE\"\r\n            _BFW_CSS_INACTIVE_=\"TIFDINACTIVE\" _BFW_CSS_DEFAULT_=\"TIFDDEFAULT\" _BFW_CSS_ERROR_=\"TIFDERROR\"\r\n            _BFW_CSS_DISABLED_=\"TIFDDISABLED\"&gt;\r\n<\/span>       <span style=\"color: #339966;\">&lt;!-- ### MX_010: Replace End ########################################### --&gt;<\/span>\r\n    &lt;xsl:for-each select=\".\/HELPVALUE\"&gt;<\/pre>\n<\/blockquote>\n<p>As you can see there is also some javascript code involved:<\/p>\n<blockquote>\n<pre><span style=\"color: #339966;\">\/\/------------------------------------------------------------------------------------\r\n\/\/ MX_010: Table column headers stay at the top\r\n\/\/------------------------------------------------------------------------------------\r\n\/\/ This function hides SELECT objects\r\n<\/span>function MX_Hide_Select(obj) {\r\n\u00a0div_scrollTop\u00a0 = obj.offsetParent.offsetParent.offsetParent.scrollTop;\r\n\u00a0line_offsetTop = obj.offsetParent.offsetTop;\r\n\u00a0obj_offsetTop\u00a0 = obj.offsetTop;\r\n\u00a0\u00a0head_height\u00a0\u00a0\u00a0 = obj.offsetParent.offsetParent.firstChild.offsetHeight;\r\n\u00a0if (div_scrollTop + head_height &gt; line_offsetTop + obj_offsetTop) {\r\n\u00a0\u00a0return 'hidden';\r\n\u00a0} else {\r\n\u00a0\u00a0return 'visible';\r\n\u00a0}\r\n}<\/pre>\n<\/blockquote>\n<p>You have to provide that code in a separate JS file and of course you need to link this JS file in the\u00a0HTML header definitions in your XSL:<\/p>\n<p>&lt;SCRIPT LANGUAGE=&#8221;JavaScript&#8221; SRC=&#8221;SAPR3-WR-Z_YOUR_JS_FILE.JS&#8221;\/&gt;<\/p>\n<p><strong><span style=\"text-decoration: underline;\">Some remarks:<\/span><\/strong><\/p>\n<p>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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_links_to":"","_links_to_target":""},"categories":[52],"tags":[40,54],"_links":{"self":[{"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/posts\/670"}],"collection":[{"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":27,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":2166,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/posts\/670\/revisions\/2166"}],"wp:attachment":[{"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/websha.de\/xstepcafe\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}