<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Efficy Overflow Q&amp;A - Recent questions tagged diplay</title>
<link>https://overflow.efficy.io/?qa=tag/diplay</link>
<description>Powered by Question2Answer</description>
<item>
<title>Efficy customs 2014 - Problem with DetailSpecial display handling (solved)</title>
<link>https://overflow.efficy.io/?qa=52/efficy-customs-problem-detailspecial-display-handling-solved</link>
<description>&lt;p&gt;&lt;strong&gt;[Fixed. See below.]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I have adapted a custom wich appears in the Projects entity, in a new tab (a financial dashboard). Everything works fine, but still, I meet an impossibility to display normaly this dashboard by clicking on the new tab. Here is everything, in detail:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MacroConsultCustom.txt&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the &quot;Avalable details&quot; section, &lt;em&gt;DetailTabsButtons.Pro&lt;/em&gt; contains the new tab (&lt;em&gt;Financial&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;In the &quot;General page&quot; layout, &quot;ConsultQueries.Proj.Financial&quot; all the required Queries (Runquery)...&lt;/li&gt;
&lt;li&gt;In the &quot;Consult Detail Area&quot; section, &lt;em&gt;DetailTabs&lt;/em&gt; contains the Image, Label and Title definitions of my new tab&lt;/li&gt;
&lt;li&gt;In the &quot;Consult Detail Content&quot; section, &lt;em&gt;DetailSwitch.Proj.Financial&lt;/em&gt; uses the macro &quot;DetailSpecial&quot;&lt;/li&gt;
&lt;li&gt;Still in the &quot;Consult Detail Content&quot; section, &lt;em&gt;DetailSpecial.Proj.Financial&lt;/em&gt; contains the front-end code of the dashboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What does not work :&lt;/strong&gt;&lt;br&gt;
If I click on my tab, the screen goes white, displaying a top frame, which only contains the value of the first Efficy DB field to be displayed (returned by a query). The code is a javascript line :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var poin = &amp;lt;%OnField(&quot;POIN&quot;,query=&quot;POIN&quot;,then=&quot;0&quot;,else=&quot;%%GetField('POIN',query='POIN')&quot;)%&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;... so all I see on the screen is the value of 'POIN'. No more interface, no more Efficy...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What works :&lt;/strong&gt;&lt;br&gt;
If I remove all the code present in &quot;DetailSpecial.Proj.Financial&quot;, replacing it by &quot;Toto&quot;, and save the custom, I'm suddenly perfectly able to display my tab and its content (Toto) : it looks fine.&lt;br&gt;
But here is the 'straaange&quot; : if I put my display code back in &quot;DetailSpecial.Proj.Financial&quot;, save the custom, and refresh the page by using F5, my dashboard appears!&lt;/p&gt;

&lt;p&gt;Then, if I log out, login again, and try to go to the Financial dashboard, exerything explodes again.&lt;/p&gt;

&lt;p&gt;Any hint ? Could it be about delaying the execution of something somewhere ? Any idea ?&lt;/p&gt;

&lt;p&gt;Thanks in advance, and thanks for reading that looooooong question. ;-)&lt;/p&gt;

&lt;hr&gt;

&lt;p&gt;&lt;strong&gt;UPDATE : FIXED on 16/10/2014&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All my problem were due to the usage of some &quot;document.write()&quot; in the javascript of the custom I had to adapt to 2014 edition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem was:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;« document.write » can't be called from an asynchronous script, because it's detached from the document. As Efficy 2014 uses async scripts for the display, its usage can write over the top of global efficy responsive display template. The result if often a blank page, displaying only what the first « document.write » of your custom has to display, and ignoring the rest of your script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The solution that worked for me:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ban the use of any document.write in 2014 customs. I had toimplement some « .innerHTML » properties to populate blank &lt;span&gt; tags or  tags. This approach does not break the display flow of Efficy 2014.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simple example of replacement:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;Total PO Budget :&amp;lt;/td&amp;gt;
        &amp;lt;td class=&quot;right-bold&quot;&amp;gt;
            &amp;lt;script&amp;gt;
                var poin = &amp;lt;%OnField(&quot;POIN&quot;,query=&quot;POIN&quot;,then=&quot;0&quot;,else=&quot;%%GetField('POIN',query='POIN')&quot;)%&amp;gt;;
                var total = (parseInt(poin,10));
                document.write(total);
            &amp;lt;/script&amp;gt; €
        &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;
    &amp;lt;tr&amp;gt;
        &amp;lt;td&amp;gt;Total PO Budget :&amp;lt;/td&amp;gt;
        &amp;lt;td class=&quot;right-bold&quot;&amp;gt;&amp;lt;span id=&quot;totalPOIN&quot;&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;script&amp;gt;
            var poin = &amp;lt;%OnField(&quot;POIN&quot;,query=&quot;POIN&quot;,then=&quot;0&quot;,else=&quot;%%GetField('POIN',query='POIN')&quot;)%&amp;gt;;
            var total = (parseInt(poin,10));
            //document.write(total);
            document.getElementById(&quot;totalPOIN&quot;).innerHTML = total;
        &amp;lt;/script&amp;gt; €
        &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;More advanced example of replacement, using &amp;lt;#repeat&amp;gt; loops:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;
    &amp;lt;%GetDataGrid(query=&quot;TasksStatus&quot;,TemplateText=|&amp;lt;#repeat&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;#F=role&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td class=&quot;center-txt no-warp&quot;&amp;gt;&amp;lt;#I=consumed;#EMPTY=0;#ELSE=&amp;lt;#F=consumed&amp;gt;&amp;gt; €&amp;lt;/nowarp&amp;gt; / &amp;lt;#F=budget&amp;gt; €&amp;lt;/td&amp;gt;
            &amp;lt;td class=&quot;center-txt no-warp&quot;&amp;gt;&amp;lt;#F=DONE&amp;gt; / &amp;lt;#F=forecast&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;
                &amp;lt;script&amp;gt;
                    if ((&amp;lt;#F=DONE&amp;gt;) &amp;gt; (&amp;lt;#F=forecast&amp;gt;))
                        document.write('&amp;lt;img src=&quot;http://chart.apis.google.com/chart?chbh=a&amp;amp;chs=200x12&amp;amp;cht=bhg&amp;amp;chco=FF0000&amp;amp;chds=0,&amp;lt;#F=forecast&amp;gt;&amp;amp;chd=t:&amp;lt;#F=done&amp;gt;&quot; width=&quot;200&quot; height=&quot;12&quot; alt=&quot;&quot; /&amp;gt;'); 
                    else 
                        document.write('&amp;lt;img src=&quot;http://chart.apis.google.com/chart?chbh=a&amp;amp;chs=200x12&amp;amp;cht=bhg&amp;amp;chco=049900&amp;amp;chds=0,&amp;lt;#F=forecast&amp;gt;&amp;amp;chd=t:&amp;lt;#F=done&amp;gt;&quot; width=&quot;200&quot; height=&quot;12&quot; alt=&quot;&quot; /&amp;gt;');
                &amp;lt;/script&amp;gt;
                &amp;lt;span class=&quot;no-warp&quot;&amp;gt;&amp;lt;script&amp;gt;var percentage = Math.round((&amp;lt;#F=DONE&amp;gt;/&amp;lt;#F=FORECAST&amp;gt;)*100); document.write(&quot; &quot;+percentage)&amp;lt;/script&amp;gt; %&amp;lt;/span&amp;gt;
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/#repeat&amp;gt;|)%&amp;gt;
&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;table&amp;gt;
    &amp;lt;script&amp;gt; var idCmpt=0; &amp;lt;/script&amp;gt;
    &amp;lt;%GetDataGrid(query=&quot;TasksStatus&quot;,TemplateText=|&amp;lt;#repeat&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;#F=role&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td class=&quot;center-txt no-warp&quot;&amp;gt;&amp;lt;#I=consumed;#EMPTY=0;#ELSE=&amp;lt;#F=consumed&amp;gt;&amp;gt; €&amp;lt;/nowarp&amp;gt; / &amp;lt;#F=budget&amp;gt; €&amp;lt;/td&amp;gt;
            &amp;lt;td class=&quot;center-txt no-warp&quot;&amp;gt;&amp;lt;#F=DONE&amp;gt; / &amp;lt;#F=forecast&amp;gt;&amp;lt;/td&amp;gt;
            &amp;lt;td&amp;gt;&amp;lt;img id=&quot;idChartToReplace&quot; src=&quot;&quot; width=&quot;200&quot; height=&quot;12&quot; alt=&quot;&quot; /&amp;gt;
                &amp;lt;script&amp;gt;
                    var divCharId = &quot;TasksStatusChartImg&quot;+idCmpt;
                    document.getElementById(&quot;idChartToReplace&quot;).id = divCharId ;
                    if ((&amp;lt;#F=DONE&amp;gt;) &amp;gt; (&amp;lt;#F=forecast&amp;gt;)) {
                        document.getElementById(divCharId).src = &quot;http://chart.apis.google.com/chart?chbh=a&amp;amp;chs=200x12&amp;amp;cht=bhg&amp;amp;chco=FF0000&amp;amp;chds=0,&amp;lt;#F=forecast&amp;gt;&amp;amp;chd=t:&amp;lt;#F=done&amp;gt;&quot;; 
                    }
                    else {
                        document.getElementById(divCharId).src = &quot;http://chart.apis.google.com/chart?chbh=a&amp;amp;chs=200x12&amp;amp;cht=bhg&amp;amp;chco=049900&amp;amp;chds=0,&amp;lt;#F=forecast&amp;gt;&amp;amp;chd=t:&amp;lt;#F=done&amp;gt;&quot;; 
                    }
                &amp;lt;/script&amp;gt;
                &amp;lt;span id=&quot;idChartPercentToReplace&quot; class=&quot;no-warp&quot;&amp;gt;&amp;lt;/span&amp;gt;
                &amp;lt;script&amp;gt;
                    var spanCharPercentId = &quot;TasksStatusChartPercent&quot;+idCmpt;
                    document.getElementById(&quot;idChartPercentToReplace&quot;).id = spanCharPercentId;
                    var percentage = Math.round((&amp;lt;#F=DONE&amp;gt;/&amp;lt;#F=FORECAST&amp;gt;)*100); 
                    //document.write(&quot; &quot;+percentage+&quot; %&quot;);
                    document.getElementById(spanCharPercentId).innerHTML = &quot; &quot;+percentage+&quot; %&quot;;
                    idCmpt++;
                &amp;lt;/script&amp;gt;
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/#repeat&amp;gt;|)%&amp;gt;
&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Efficy Developers</category>
<guid isPermaLink="true">https://overflow.efficy.io/?qa=52/efficy-customs-problem-detailspecial-display-handling-solved</guid>
<pubDate>Wed, 15 Oct 2014 11:37:56 +0000</pubDate>
</item>
</channel>
</rss>