<?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>GridField Dynamic Column</title><link>https://community.appian.com/discussions/f/user-interface/38255/gridfield-dynamic-column</link><description>This is the code i wrote my requirement is to 
 im fetching the data&amp;#39;s from DB 
 lets say i have 11 data in total , 
 i need it in a dynamic column in gridField like (no of col can be : 2,4,6) 
 local!data : DB datas, 
 local!noOfCol : (3,4,5) -&amp;gt; any</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: GridField Dynamic Column</title><link>https://community.appian.com/thread/144118?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2025 09:20:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ad56557a-25e6-4708-81fa-2be7b002b033</guid><dc:creator>Keshav Dadhich</dc:creator><description>&lt;p&gt;Hi Dinesh,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve made some updates to your code to dynamically group the data into columns based on a configurable number of columns (e.g., 2, 4, or 6). These changes should help render the grid as you need.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the updated code.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    {lookupId: 1, displayLabel: &amp;quot;dove&amp;quot;},
    {lookupId: 2, displayLabel: &amp;quot;download&amp;quot;},
    {lookupId: 3, displayLabel: &amp;quot;drafting-compass&amp;quot;},
    {lookupId: 4, displayLabel: &amp;quot;dragon&amp;quot;},
    {lookupId: 5, displayLabel: &amp;quot;draw-polygon&amp;quot;},
    {lookupId: 6, displayLabel: &amp;quot;drum&amp;quot;},
    {lookupId: 7, displayLabel: &amp;quot;drum-steelpan&amp;quot;},
    {lookupId: 8, displayLabel: &amp;quot;drumstick-bite&amp;quot;},
    {lookupId: 9, displayLabel: &amp;quot;dumbbell&amp;quot;}
  },
  local!noOfCol: 3,
  local!groupedData: a!forEach(
    items: enumerate(
      ceiling(count(local!data) / local!noOfCol)
    ),
    expression: reduce(
      a!update,
      a!map(),
      merge(
        a!forEach(items: enumerate(local!noOfCol),expression: concat(&amp;quot;item&amp;quot;,fv!index)),
        index(
          local!data,
          enumerate(local!noOfCol) + (((fv!index - 1) * local!noOfCol) + 1),
          null
        )
      )
    )
  ),
  a!gridField(
    label: &amp;quot;Icons&amp;quot;,
    labelPosition: &amp;quot;COLLAPSED&amp;quot;,
    data: local!groupedData,
    columns: a!forEach(
      items: enumerate(local!noOfCol),
      expression: a!gridColumn(
        label: concat(&amp;quot;Col &amp;quot;,fv!index),
        value: a!richTextDisplayField(
          label: &amp;quot;Lookup Icons&amp;quot;,
          labelPosition: &amp;quot;COLLAPSED&amp;quot;,
          value: a!richTextIcon(
            icon: index(
              index(fv!row,concat(&amp;quot;item&amp;quot;,fv!index),null),
              &amp;quot;displayLabel&amp;quot;,
              null
            ),
            size: &amp;quot;MEDIUM&amp;quot;
          )
        ),
        align: &amp;quot;CENTER&amp;quot;
      )
    ),
    spacing: &amp;quot;DENSE&amp;quot;,
    borderStyle: &amp;quot;STANDARD&amp;quot;,
    shadeAlternateRows: false
  )
)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Let me know whether my understanding is correct!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>