{"id":2642,"date":"2022-06-24T11:55:36","date_gmt":"2022-06-24T11:55:36","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=2642"},"modified":"2022-11-24T14:52:05","modified_gmt":"2022-11-24T14:52:05","slug":"tutorial-cell-repeater","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=2642","title":{"rendered":"Cell Repeater"},"content":{"rendered":"\n<h3 id=\"block-ef0794b0-fb17-49df-beaa-060800c8be59\">Desired Output<\/h3>\n\n\n\n<p id=\"block-9a445d99-d4a3-4528-8cb8-0cd43ea2aeb0\">In DocuMotor, it is possible to populate tables horizontally, while also controlling their length, by using a cell repeater binding. An overview of this function is presented in the image below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"576\" src=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1-1024x576.png\" alt=\"\" class=\"wp-image-2643\" srcset=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1-1024x576.png 1024w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1-300x169.png 300w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1-768x432.png 768w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1-1536x864.png 1536w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Overview-1.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 id=\"block-46dc67c9-2a88-46b9-ab4f-eeb3aee0cbf1\">Sample Data<\/h3>\n\n\n\n<p id=\"block-0c778a55-6e7f-4a6c-9b81-9990752c95f7\">The data set that will be used in this tutorial can be found below:<\/p>\n\n\n\n<pre id=\"block-add9eca3-c692-4052-8159-b3d8a66da065\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n\t\"Cars\": [\n\t\t{\n\t\t\t\"Brand\": \"Volkswagen\",\n\t\t\t\"Model\": \"Cabriolet\",\n\t\t\t\"Color\": \"Puce\",\n\t\t\t\"Year\": 1993\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Lincoln\",\n\t\t\t\"Model\": \"Town Car\",\n\t\t\t\"Color\": \"Green\",\n\t\t\t\"Year\": 1989\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"GMC\",\n\t\t\t\"Model\": \"Envoy XUV\",\n\t\t\t\"Color\": \"Indigo\",\n\t\t\t\"Year\": 2005\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Ford\",\n\t\t\t\"Model\": \"Explorer\",\n\t\t\t\"Color\": \"Puce\",\n\t\t\t\"Year\": 1994\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Dodge\",\n\t\t\t\"Model\": \"Journey\",\n\t\t\t\"Color\": \"Maroon\",\n\t\t\t\"Year\": 2012\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Dodge\",\n\t\t\t\"Model\": \"Journey\",\n\t\t\t\"Color\": \"Pink\",\n\t\t\t\"Year\": 2010\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Nissan\",\n\t\t\t\"Model\": \"Maxima\",\n\t\t\t\"Color\": \"Aquamarine\",\n\t\t\t\"Year\": 2012\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Kia\",\n\t\t\t\"Model\": \"Rio\",\n\t\t\t\"Color\": \"Green\",\n\t\t\t\"Year\": 2005\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Nissan\",\n\t\t\t\"Model\": \"Sentra\",\n\t\t\t\"Color\": \"Fuscia\",\n\t\t\t\"Year\": 2008\n\t\t},\n\t\t{\n\t\t\t\"Brand\": \"Cadillac\",\n\t\t\t\"Model\": \"XLR\",\n\t\t\t\"Color\": \"Crimson\",\n\t\t\t\"Year\": 2005\n\t\t}\n\t]\n}<\/code><\/pre>\n\n\n\n<h3 id=\"block-0302cbf6-7088-4d8c-b8a8-c934cfa922b9\">Word Template<\/h3>\n\n\n\n<p id=\"block-28af3427-d081-464e-8ef9-46ec22f42b3e\">The Word template, along with all the required bindings, that are used in this tutorial can be downloaded using the button below:<\/p>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-49e1f27b-6be2-423a-91de-fdf2c67ec1b9\" href=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Cell-Repeater-Tutorial.docx\">Cell-Repeater-Tutorial<\/a><a href=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Cell-Repeater-Tutorial.docx\" class=\"wp-block-file__button\" download aria-describedby=\"wp-block-file--media-49e1f27b-6be2-423a-91de-fdf2c67ec1b9\">Download<\/a><\/div>\n\n\n\n<h3>Transformation<\/h3>\n\n\n\n<p>In order for the cell repeater to function properly, a particular model needs to be used when transforming the data. More specifically, the following needs to be included in the transformation:<\/p>\n\n\n\n<pre id=\"block-add9eca3-c692-4052-8159-b3d8a66da065\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n  \"options\":{\n    \"direction\": \"lrtb\" \n  },\n  \"cells\":[{\"testkey\":\"testvalue\"}] \n}<\/code><\/pre>\n\n\n\n<ul><li><strong>options&nbsp;<\/strong>(case sensitive, required) \u2013 defines the general options for the cell repeater processing.<\/li><li><strong>direction&nbsp;<\/strong>(case sensitive, required) \u2013 string parameter. Defines the direction with which the cells will be expanded. Currently, only the following value is supported for this parameter:<ul><li>\u201c<strong>lrtb<\/strong>\u201d (left-right-top-bottom)<\/li><\/ul><\/li><li><strong>cells<\/strong>&nbsp;(case sensitive, required) \u2013 list parameter. This is where the array that holds the table&#8217;s data is added.<\/li><\/ul>\n\n\n\n<p>In this tutorial, the transformation below is used:<\/p>\n\n\n\n<pre id=\"block-add9eca3-c692-4052-8159-b3d8a66da065\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n  \"cellRepeater\": {\n    \"options\": {\n      \"direction\": 'lrtb'\n    },\n    \"cells\": Cars[]\n  }\n}<\/code><\/pre>\n\n\n\n<p>This will result in the following output:<\/p>\n\n\n\n<pre id=\"block-add9eca3-c692-4052-8159-b3d8a66da065\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n  \"cellRepeater\": {\n    \"options\": {\n      \"direction\": \"lrtb\"\n    },\n    \"cells\": [\n      {\n        \"Brand\": \"Volkswagen\",\n        \"Model\": \"Cabriolet\",\n        \"Color\": \"Puce\",\n        \"Year\": 1993\n      },\n      {\n        \"Brand\": \"Lincoln\",\n        \"Model\": \"Town Car\",\n        \"Color\": \"Green\",\n        \"Year\": 1989\n      },\n      {\n        \"Brand\": \"GMC\",\n        \"Model\": \"Envoy XUV\",\n        \"Color\": \"Indigo\",\n        \"Year\": 2005\n      },\n      {\n        \"Brand\": \"Ford\",\n        \"Model\": \"Explorer\",\n        \"Color\": \"Puce\",\n        \"Year\": 1994\n      },\n      {\n        \"Brand\": \"Dodge\",\n        \"Model\": \"Journey\",\n        \"Color\": \"Maroon\",\n        \"Year\": 2012\n      },\n      {\n        \"Brand\": \"Dodge\",\n        \"Model\": \"Journey\",\n        \"Color\": \"Pink\",\n        \"Year\": 2010\n      },\n      {\n        \"Brand\": \"Nissan\",\n        \"Model\": \"Maxima\",\n        \"Color\": \"Aquamarine\",\n        \"Year\": 2012\n      },\n      {\n        \"Brand\": \"Kia\",\n        \"Model\": \"Rio\",\n        \"Color\": \"Green\",\n        \"Year\": 2005\n      },\n      {\n        \"Brand\": \"Nissan\",\n        \"Model\": \"Sentra\",\n        \"Color\": \"Fuscia\",\n        \"Year\": 2008\n      },\n      {\n        \"Brand\": \"Cadillac\",\n        \"Model\": \"XLR\",\n        \"Color\": \"Crimson\",\n        \"Year\": 2005\n      }\n    ]\n  }\n}<\/code><\/pre>\n\n\n\n<h3>Binding<\/h3>\n\n\n\n<p>The main binding of this function is the following:<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#4600b4\" class=\"has-inline-color\">{&#8220;BindingType&#8221;:&#8221;RepeatTableCells&#8221;,&#8221;BindingKey&#8221;:&#8221;<\/mark>s<mark style=\"background-color:rgba(0, 0, 0, 0);color:#4600b4\" class=\"has-inline-color\">ampleKey&#8221;}<\/mark><\/p>\n\n\n\n<p>The binding must enclose the entire table and not only a row or a cell, as seen in the example below. In the binding, sampleKey needs to be replaced with the array that holds the information that is supposed to be displayed in the table&#8217;s cells. In this case, sampleKey is replaced with cellRepeater.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"953\" height=\"234\" src=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/BindingExample.png\" alt=\"\" class=\"wp-image-2649\" srcset=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/BindingExample.png 953w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/BindingExample-300x74.png 300w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/BindingExample-768x189.png 768w\" sizes=\"(max-width: 953px) 100vw, 953px\" \/><\/figure>\n\n\n\n<p>The table&#8217;s first cell is used as a template for the remaining cells, but despite that, all cells in the template need to be bound to the corresponding keys in the output data. For example, in this tutorial, the word Brand is bound to DocuMotor&#8217;s output data using the following field binding:<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#4600b4\" class=\"has-inline-color\">{&#8220;BindingType&#8221;:&#8221;Field&#8221;,&#8221;BindingKey&#8221;:&#8221;Brand&#8221;}<\/mark><\/p>\n\n\n\n<p>Furthermore, the number of cells in the first row of the table in the template defines how many cells will be used for each row of the final document, and by extension the table&#8217;s size. It is also worth mentioning that besides expanding the table&#8217;s cells and rows, in case less data than the cells in the template is outputted, the table template will shrink to fit the size of the data.<\/p>\n\n\n\n<h3>Result<\/h3>\n\n\n\n<p>With a cell repeater binding, it is possible to populate the cells of a table horizontally instead of vertically while starting from different starting points and controlling the table&#8217;s length.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"647\" src=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2-1024x647.png\" alt=\"\" class=\"wp-image-2654\" srcset=\"https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2-1024x647.png 1024w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2-300x190.png 300w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2-768x485.png 768w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2-1536x971.png 1536w, https:\/\/info.documotor.com\/wp-content\/uploads\/2022\/06\/Result-2.png 1761w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Desired Output In DocuMotor, it is possible to populate tables horizontally, while also controlling their length, by using a cell repeater binding. An overview of this function is presented in the image below: Sample Data The data set that will be used in this tutorial can be found below: Word Template The Word template, along [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"parent":2549,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/2642"}],"collection":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2642"}],"version-history":[{"count":13,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/2642\/revisions"}],"predecessor-version":[{"id":4011,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/2642\/revisions\/4011"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/2549"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}