Editable Grid - edit only specific rows based on a link click

Hi All,

I have a user case below, where in "comments column" should be editable based on click of a "edit" icon.  Below is the code snippet with in the grid.

a!textField(
label: "Comments" & fv!item,
value: fv!item.commenttext,
saveInto: {
fv!item.commenttext
},
readOnly: false(),     --->>>>>   how can I make the row editable when a user clicks on edit icon ?
),
if(
fv!item.status= "NON-EDIT",
a!textField(
label: "Action" & fv!item,
value: "",
readOnly: true
),
a!richTextDisplayField(
value: a!richTextIcon(
icon: "edit",
caption: "Edit",
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save()
}
)
),
align: "CENTER"
)


Any help is appreciated Slight smile

  Discussion posts and replies are publicly visible

Parents
  • try the below code it may help for your usecase

    a!localVariables(
      local!items: {
        {item: "salt", qty: 1},
        {item: "sugar", qty: 2}
      },
      local!readOnly,
      a!gridLayout(
        label: "Products",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Quantity"),
          
          a!gridLayoutHeaderCell(label: "Edit Quantity")
         
        },
        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: "edit",
                    caption: "Edit",
                    link: a!dynamicLink(
                      value: false(),
                      saveInto: {
                       
                       a!save(local!readOnly,insert(local!readOnly,save!value,fv!index))
                      }
                    )
                  ),
                  align: "CENTER"
            )
          
          }
        ),
        
      )
    )
    )

Reply
  • try the below code it may help for your usecase

    a!localVariables(
      local!items: {
        {item: "salt", qty: 1},
        {item: "sugar", qty: 2}
      },
      local!readOnly,
      a!gridLayout(
        label: "Products",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Quantity"),
          
          a!gridLayoutHeaderCell(label: "Edit Quantity")
         
        },
        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: "edit",
                    caption: "Edit",
                    link: a!dynamicLink(
                      value: false(),
                      saveInto: {
                       
                       a!save(local!readOnly,insert(local!readOnly,save!value,fv!index))
                      }
                    )
                  ),
                  align: "CENTER"
            )
          
          }
        ),
        
      )
    )
    )

Children