<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Nested Grid</title><link>https://community.appian.com/discussions/f/user-interface/22183/nested-grid</link><description>Hi Experts, 
 
 I have a user requirement for which I need to create a Nested Grid. Structure is as given below 
 
 
 For this I have created 
 CDT 1 have fields as below: 
 
 
 where field &amp;quot;grid&amp;quot; is of type cdt 2 which have structure as below 
 
 Now</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Nested Grid</title><link>https://community.appian.com/thread/86910?ContentTypeID=1</link><pubDate>Tue, 12 Oct 2021 14:46:39 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a6b5de14-8545-4204-812c-f9408a2ec9d5</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;ve whipped up this quick and very-slightly-simplified demo that should show how to structure this in general.&amp;nbsp; The main change you&amp;#39;d need to make is swapping back in your actual nested CDT, instead of my fake local variable (but this way anyone can copy/paste and run this code).&lt;/p&gt;
&lt;p&gt;I believe i&amp;#39;ve identified a primary potential point of confusion which is, whenever you save into one of the lower row values, you&amp;#39;ll need to save it up to the main original CDT value instead of the local copy.&amp;nbsp; This gets tricky with a nested a!forEach() call, but this can be solved with strategic use of placeholder local variables within each loop.&lt;br /&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  
  local!nestedCdt: { /* you will swap out this value with your nested CDT rule input */
    {
      index: 1,
      grid: {
        {id: 1, text: &amp;quot;abc&amp;quot;},
        {id: 2, text: &amp;quot;qwer&amp;quot;}
      }
    },
    {
      index: 2,
      grid: {
        {id: 1, text: &amp;quot;def&amp;quot;},
        {id: 2, text: &amp;quot;zxcv&amp;quot;},
        {id: 3, text: &amp;quot;12345&amp;quot;}
      }
    }
  },
  local!currentCount: max(local!nestedCdt.index), /* this variable should mainly be informative, probably not the active element you loop over */
  local!maxGrids: 6,
  local!fullGrids: local!currentCount &amp;gt;= local!maxGrids,
  
  a!sectionLayout(
    label: &amp;quot;Demonstration Multi-Grid for Nested CDT&amp;quot;,
    contents: {
      a!richTextDisplayField(  /* use this instead of a!linkField() */
        value: a!richTextItem(
          text: {
            a!richTextIcon(icon: &amp;quot;plus-circle&amp;quot;),
            &amp;quot; Add Grid &amp;quot; &amp;amp; local!currentCount + 1
          },
          size: &amp;quot;MEDIUM&amp;quot;,
          linkStyle: &amp;quot;STANDALONE&amp;quot;,
          style: if(local!fullGrids, &amp;quot;EMPHASIS&amp;quot;, null()),
          color: if(local!fullGrids, &amp;quot;SECONDARY&amp;quot;, null()),

          link: a!dynamicLink(
            showWhen: not(local!fullGrids),
            saveInto: {
              a!save(
                local!nestedCdt,
                append(
                  local!nestedCdt,
                  {
                    index: local!currentCount + 1,
                    grid: {}
                  }
                )
              )
            }
          )
        )
      ),
      
      a!forEach(
        local!nestedCdt,
        a!localVariables(
          local!currentEntry: fv!item,
          local!parentIndex: fv!index,
          a!gridLayout(
            label: &amp;quot;Grid for Index &amp;quot; &amp;amp; local!currentEntry.index,
            headerCells: {
              a!gridLayoutHeaderCell(label: &amp;quot;Id&amp;quot;),
              a!gridLayoutHeaderCell(label: &amp;quot;Text&amp;quot;)
            },
            rows: a!forEach(
              local!currentEntry.grid,
              a!gridRowLayout(
                id: local!currentEntry.index,
                contents: {
                  a!richTextDisplayField(
                    value: fv!item.id
                  ),
                  a!textField(
                    label: &amp;quot;Text Column&amp;quot;,
                    value: fv!item.text,
                    saveInto: {
                      /*fv!item.text*/
                      /* the SaveInto here will need to save straight to the parent CDT, not the local copy */
                      a!save(
                        local!nestedCdt[local!parentIndex].grid[fv!index].text,
                        save!value
                      )
                    }
                  )
                }
              )
            ),
            addRowLink: a!dynamicLink(
              label: &amp;quot;Add Row&amp;quot;,
              saveInto: {
                a!save(
                  fv!item.grid,
                  append(
                    fv!item.grid,
                    {
                      id: if(
                        isnull(property(fv!item.grid, &amp;quot;id&amp;quot;, null())),
                        1,
                        max(fv!item.grid.id) + 1
                      ),
                      text: &amp;quot;[new row added]&amp;quot;
                    }
                  )
                )
              }
            )
          )
        )
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nested Grid</title><link>https://community.appian.com/thread/86907?ContentTypeID=1</link><pubDate>Tue, 12 Oct 2021 14:15:14 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:16d0e793-222f-424f-b286-a90f1a1a4fb5</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Theoretically this should work (though I wouldn&amp;#39;t use the term &amp;quot;nested grid&amp;quot; as it will give people the wrong idea, what you really seem to be after is an array of grids based on the inner contents of a nested CDT).&amp;nbsp; However I&amp;#39;m really confused by what you&amp;#39;re doing with your &amp;quot;ri!multiFeeGrid&amp;quot; when clicking the &amp;quot;Add Amendments&amp;quot; link.&amp;nbsp; This is weirdly recursive and presumably doesn&amp;#39;t account for whether &amp;quot;ri!multiFeeGrid&amp;quot; is an Array (i assume it is?) - in essence it looks as if local!grid is being set to the value of ri!multiFeeGrid but then upon link click you&amp;#39;re appending a new copy of the CDT at the end of the array but with the entire contents of the prior value of &amp;quot;local!grid&amp;quot;, which at best won&amp;#39;t work, and at worst will break horribly.&amp;nbsp;&lt;br /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/13/pastedimage1634048311642v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I suggest you take a step back here and analyze what you actually intend this link to do, and retry.&amp;nbsp;&amp;nbsp; From the looks of it, you should probably totally remove &amp;quot;local!grid&amp;quot; and rework all the places you&amp;#39;re trying to use that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>