{"id":1388,"date":"2008-09-11T03:45:46","date_gmt":"2008-09-11T08:45:46","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/docs\/?page_id=1388"},"modified":"2023-04-26T14:01:36","modified_gmt":"2023-04-26T19:01:36","slug":"using-freemarker-to-control-the-layout-of-rows","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/using-freemarker-to-control-the-layout-of-rows","title":{"rendered":"Control Row Layout with Freemarker"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview<\/h3>\n\n\n\n<p>There may be times when the standard look of a Multiple Row Data List may not work for you. For instance, let&#8217;s say the row you want to print is relatively short (perhaps only one field), and there are many rows to display. Rather than having all the data in one column, you could use Freemarker logic to print some of that data into a second column. <\/p>\n\n\n\n<p>As an example, lets take a look at a list of 50 states. Here is a before picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"\/docs\/vue-images\/statesColumn.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>As you can see, there is far too much wasted space. Instead, using Freemarker, we can have output that looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"\/docs\/vue-images\/statesGrid.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/statesGrid.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>We are now able to utilize the screen much more efficiently. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration<\/h3>\n\n\n\n<p>Let&#8217;s walk through how this is done:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>After compiling your application, enter m-Painter and Toggle the source view.<\/li>\n\n\n\n<li>For simplicity, remove the Table Header. Find <code>&lt;thead><\/code> and delete all the way to:<code> &lt;\/thead><\/code>.<\/li>\n\n\n\n<li>To create a screen like the one above, we are going to use Freemarker to create looping logic in the HTML.<\/li>\n\n\n\n<li>Find this section of text (Beginning with the #list tag and going to the \/#list tag):<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- &lt;#list table_rows as row> -->\n  &lt;tr>\n    &lt;td class=\"text-left\" nowrap=\"nowrap\">${row.FIELD?html}&lt;\/td>\n  &lt;\/tr>\n&lt;!-- &lt;\/#list> --><\/code><\/pre>\n\n\n\n<p>And replace it with this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;tr>&lt;td>&lt;table class=\"table\">\n  &lt;!-- &lt;#assign counter = 0> -->\n  &lt;!-- &lt;#list table_rows as row> -->\n    &lt;!-- &lt;#if counter == 5> -->\n      &lt;\/table>&lt;\/td>&lt;td>&lt;table class=\"table\">\n      &lt;!-- &lt;#assign counter = 0> -->\n    &lt;!-- &lt;\/#if> -->\n    &lt;tr>&lt;td class=\"text-left\" nowrap=\"nowrap\">\n      ${row.FIELD?html}\n    &lt;\/td>&lt;\/tr>\n  &lt;!-- &lt;#assign counter=counter + 1> -->\n  &lt;!-- &lt;\/#list> -->\n&lt;\/table>&lt;\/td>&lt;\/tr><\/code><\/pre>\n\n\n\n<p>Here is a review of the above text:<\/p>\n\n\n\n<p>Line 1 &#8212; Create a nested row, data cell, and table.<\/p>\n\n\n\n<p>Line 2 &#8212; Create a variable called counter and set it equal to 0.<\/p>\n\n\n\n<p>Line 3 &#8212; This is the default code that generates which tells the code to begin handling data from the DB<\/p>\n\n\n\n<p>Line 4 &#8212; Immediately check to see if the counter variable is equal to 5. This will never be the case until the code loops through 5 times. This number can be changed and will control the number of records printed per column.<\/p>\n\n\n\n<p>Line 5 &#8212; If that was the 5th row, end the nested table and data cell. Immediately create a new one. This is what allows the tables to be placed on the same row.<\/p>\n\n\n\n<p>Line 6 &#8212; Reassign the counter variable back to 0 to start all over again.<\/p>\n\n\n\n<p>Line 7 &#8212; End the if logic.<\/p>\n\n\n\n<p>Line 8 &#8212; Start a new Table row and Table data cell. <\/p>\n\n\n\n<p>Line 9 &#8212; Print the field. Please replace FIELD with the actual name of your field.<\/p>\n\n\n\n<p>Line 10 &#8212; End the Table row and Table data created on Line 8.<\/p>\n\n\n\n<p>Line 11 &#8212; Reassign the counter to add 1 to its current value.<\/p>\n\n\n\n<p>Line 12 &#8212; End the looping control that began on Line 3. When this is reached, there are no more records to print.<\/p>\n\n\n\n<p>Line 13 &#8212; End the nested table, Table Cell, and Table Row that began in Line 1.<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-alert\">Your application, by default, will still only show 10 rows at a time. Please be sure to go into Application Properties -> Program Options. Set the &#8220;Maximum Rows to Display&#8221; value accordingly. Additionally, change the &#8220;Automatically Save Row Count&#8221; to &#8216;No&#8217;. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">Be sure to change your field name from FIELD to your actual field name.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview There may be times when the standard look of a Multiple Row Data List may not work for you. For instance, let&#8217;s say the row you want to print is relatively short (perhaps only one field), and there are many rows to display. Rather than having all the data&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[265],"ht-kb-tag":[],"class_list":["post-1388","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-freemarker"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=1388"}],"version-history":[{"count":7,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1388\/revisions"}],"predecessor-version":[{"id":12704,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/1388\/revisions\/12704"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=1388"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=1388"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=1388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}