<?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>Editable Grid - edit only specific rows based on a link click</title><link>https://community.appian.com/discussions/f/new-to-appian/21999/editable-grid---edit-only-specific-rows-based-on-a-link-click</link><description>Hi All, 
 
 I have a user case below, where in &amp;quot;comments column&amp;quot; should be editable based on click of a &amp;quot;edit&amp;quot; icon. Below is the code snippet with in the grid. 
 
 a!textField( label: &amp;quot;Comments&amp;quot; &amp;amp; fv!item, value: fv!item.commenttext, saveInto: { fv!item</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Editable Grid - edit only specific rows based on a link click</title><link>https://community.appian.com/thread/86266?ContentTypeID=1</link><pubDate>Tue, 28 Sep 2021 05:03:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c687df3c-b0e3-43ef-a4a1-748b1cd29756</guid><dc:creator>Vamsy</dc:creator><description>&lt;p&gt;Hi Mike,&lt;br /&gt;Thank you for your solution, now I can make changes in editable grid at a row level :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid - edit only specific rows based on a link click</title><link>https://community.appian.com/thread/86153?ContentTypeID=1</link><pubDate>Fri, 24 Sep 2021 14:19:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bfad8114-9c4a-4cb4-b856-139fcf878169</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Using this code, if I click the &amp;quot;Edit&amp;quot; link for row 2, it makes row 1 editable, which I believe is not the intended behavior.&lt;/p&gt;
&lt;p&gt;My suggestion, using the same code approach, would be to assemble an initial array of readOnly booleans matching the length of local!items (this will follow any other data configuration such as if it&amp;#39;s passed-in from a rule input or queried).&amp;nbsp; Then for the &amp;quot;edit&amp;quot; button we will want to use &lt;em&gt;&lt;strong&gt;a!update()&lt;/strong&gt;&lt;/em&gt; instead of insert(), to update that position of the array.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!items: {
    { item: &amp;quot;salt&amp;quot;, qty: 1 },
    { item: &amp;quot;sugar&amp;quot;, qty: 2 }
  },
  local!readOnly: a!forEach(local!items, true()),
  
  a!gridLayout(
    label: &amp;quot;Products&amp;quot;,
    headerCells: {
      a!gridLayoutHeaderCell(label: &amp;quot;Item&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Quantity&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Edit Quantity&amp;quot;)
    },
    rows: a!forEach(
      items: local!items,
      expression: a!gridRowLayout(
        contents: {
          a!textField(
            value: fv!item.item,
            saveInto: { fv!item.item },
            readOnly: true(),
            
          ),
          a!textField(
            value: fv!item.qty,
            saveInto: { fv!item.qty },
            readOnly: if(
              isnull(local!readOnly),
              true,
              index(local!readOnly, fv!index, true())
            ),
            
          ),
          a!richTextDisplayField(
            value: a!richTextIcon(
              icon: &amp;quot;edit&amp;quot;,
              caption: &amp;quot;Edit&amp;quot;,
              link: a!dynamicLink(
                value: false(),
                saveInto: {
                  a!save(
                    local!readOnly,
                    a!update(local!readOnly, fv!index, false())
                  )
                }
              )
            ),
            align: &amp;quot;CENTER&amp;quot;
          )
        }
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Secondarily, I recommend for this sort of approach, to just use a row-specific local variable, as this is much less confusing in code, allows simpler operation, and is easier to test / troubleshoot / update in the future.&amp;nbsp; Here inside the a!forEach() statement defining individual rows, we simply wrap the a!gridRowLayout() statement in a new a!localVariables() and add a variable that will be scoped to just that row, i.e. &amp;quot;local!isReadOnly&amp;quot; in the below code.&amp;nbsp; This can then be saved into directly and independently by in-row controls without needing to keep track of a global array etc.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!localVariables(
  local!items: {
    { item: &amp;quot;salt&amp;quot;, qty: 1 },
    { item: &amp;quot;sugar&amp;quot;, qty: 2 }
  },
  /*local!readOnly: a!forEach(local!items, true()),*/

  a!gridLayout(
    label: &amp;quot;Products&amp;quot;,
    headerCells: {
      a!gridLayoutHeaderCell(label: &amp;quot;Item&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Quantity&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Edit Quantity&amp;quot;)
    },
    rows: a!forEach(
      items: local!items,
      expression: a!localVariables(
        local!isReadOnly: true(),
        a!gridRowLayout(
          contents: {
            a!textField(
              value: fv!item.item,
              saveInto: { fv!item.item },
              readOnly: true()
            ),
            a!textField(
              value: fv!item.qty,
              saveInto: { fv!item.qty },
              readOnly: local!isReadOnly

            ),
            a!richTextDisplayField(
              value: a!richTextIcon(
                icon: &amp;quot;edit&amp;quot;,
                caption: &amp;quot;Edit&amp;quot;,
                link: a!dynamicLink(
                  value: false(),
                  saveInto: {
                    a!save(
                      local!isReadOnly,
                      not(local!isReadOnly)
                    )
                  }
                ),
                linkStyle: &amp;quot;STANDALONE&amp;quot;
              ),
              align: &amp;quot;CENTER&amp;quot;
            )
          }
        )
      )
    )
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/62/pastedimage1632493194570v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid - edit only specific rows based on a link click</title><link>https://community.appian.com/thread/86147?ContentTypeID=1</link><pubDate>Fri, 24 Sep 2021 12:21:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b776d092-2cbf-4d4e-9a6c-fe54e1757c10</guid><dc:creator>Vamsy</dc:creator><description>&lt;p&gt;HI avinash,&lt;br /&gt;&lt;br /&gt;thank you&amp;nbsp;very much,&amp;nbsp;solution is working as expected &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Editable Grid - edit only specific rows based on a link click</title><link>https://community.appian.com/thread/86137?ContentTypeID=1</link><pubDate>Fri, 24 Sep 2021 04:55:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8e1b65b5-0f89-4c4c-98b9-b5b5828cad53</guid><dc:creator>avinashv252039</dc:creator><description>&lt;p&gt;try the below code it may help for your usecase&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!items: {
    {item: &amp;quot;salt&amp;quot;, qty: 1},
    {item: &amp;quot;sugar&amp;quot;, qty: 2}
  },
  local!readOnly,
  a!gridLayout(
    label: &amp;quot;Products&amp;quot;,
    headerCells: {
      a!gridLayoutHeaderCell(label: &amp;quot;Item&amp;quot;),
      a!gridLayoutHeaderCell(label: &amp;quot;Quantity&amp;quot;),
      
      a!gridLayoutHeaderCell(label: &amp;quot;Edit Quantity&amp;quot;)
     
    },
    rows: a!forEach(
      items: local!items,
      expression: a!gridRowLayout(
        contents: {
          a!textField(
           
            value: fv!item.item,
            saveInto: {
              fv!item.item
            },
            readOnly:true(),    
          ),
          a!textField(
          
            value: fv!item.qty,
            saveInto: {
              fv!item.qty
            },
            readOnly:if(isnull(local!readOnly),true,index(local!readOnly,fv!index,true())),    
          ),
            a!richTextDisplayField(
              value: a!richTextIcon(
                icon: &amp;quot;edit&amp;quot;,
                caption: &amp;quot;Edit&amp;quot;,
                link: a!dynamicLink(
                  value: false(),
                  saveInto: {
                   
                   a!save(local!readOnly,insert(local!readOnly,save!value,fv!index))
                  }
                )
              ),
              align: &amp;quot;CENTER&amp;quot;
        )
      
      }
    ),
    
  )
)
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>