Editable Grid - Update Rule Input on Data Change

Certified Senior Developer

Hi,

i'm trying in an editable data grid to "intercept" o simulate the "on data change" event.

i want to return a rule input value to the parent interface that called the actual interface (with an a!save of the input passed) when data in the datagrid are changed but not saved.

So if i remove a row, add a row or save data the events are present and all go right.

The problem is that i cant do an "a!save" of the ri! paramenter when dataChange in the editable datagrid.

  Discussion posts and replies are publicly visible

Parents
  • Also to note that as our editable grids do not have something such as an onChange() parameter, such as C# grid views, you will accomplish this by executing a!save()'s within the saveInto parameters of each component - your addRowLink's dynamicLink, and within each component/column in the grid.  Such as:

    a!localVariables(
      local!dataChanged: false,
      local!dataDefault: {data1: null, data2: null, data3: null},
      local!data: {
        local!dataDefault
      },
      a!formLayout(
        label: "On Change Test",
        contents: {
          a!richTextDisplayField(
            value: {
              a!richTextItem(
                showWhen: not(local!dataChanged),
                text: "Data has not been changed",
                color: "NEGATIVE"
              ),
              a!richTextItem(
                showWhen: local!dataChanged,
                text: "Data has been changed",
                color: "POSITIVE"
              )
            }
          ),
          a!gridLayout(
            headerCells: a!forEach(
              items: 1+enumerate(4),
              expression: a!gridLayoutHeaderCell(label: if(fv!isLast,"Remove",concat("Column ",fv!item)))
            ),
            columnConfigs:  a!forEach(
              items: 1+enumerate(4),
              expression: a!gridLayoutColumnConfig(width: if(fv!isLast,"ICON","DISTRIBUTE"))
            ),
            rows: a!forEach(
              items: local!data,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!textField(
                    value: fv!item.data1,
                    saveInto: {
                      a!save(local!data[fv!index].data1,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!textField(
                    value: fv!item.data2,
                    saveInto: {
                      a!save(local!data[fv!index].data2,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!textField(
                    value: fv!item.data3,
                    saveInto: {
                      a!save(local!data[fv!index].data3,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!imageField(
                    images: a!documentImage(
                      document: a!iconIndicator("REMOVE"),
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          a!save(local!data, remove(local!data, save!value)),
                          a!save(local!dataChanged,true) /* flag dataChanged value */
                        }
                      )
                    ),
                    size: "ICON"
                  )
                }
              )
            ),
            addRowLink: a!dynamicLink(
              label: "Add a Row",
              saveInto: {
                a!save(local!data,append(local!data,local!dataDefault)),
                a!save(local!dataChanged,true) /* flag dataChanged value */
              }
            )
          )
        }
      )
    )

Reply
  • Also to note that as our editable grids do not have something such as an onChange() parameter, such as C# grid views, you will accomplish this by executing a!save()'s within the saveInto parameters of each component - your addRowLink's dynamicLink, and within each component/column in the grid.  Such as:

    a!localVariables(
      local!dataChanged: false,
      local!dataDefault: {data1: null, data2: null, data3: null},
      local!data: {
        local!dataDefault
      },
      a!formLayout(
        label: "On Change Test",
        contents: {
          a!richTextDisplayField(
            value: {
              a!richTextItem(
                showWhen: not(local!dataChanged),
                text: "Data has not been changed",
                color: "NEGATIVE"
              ),
              a!richTextItem(
                showWhen: local!dataChanged,
                text: "Data has been changed",
                color: "POSITIVE"
              )
            }
          ),
          a!gridLayout(
            headerCells: a!forEach(
              items: 1+enumerate(4),
              expression: a!gridLayoutHeaderCell(label: if(fv!isLast,"Remove",concat("Column ",fv!item)))
            ),
            columnConfigs:  a!forEach(
              items: 1+enumerate(4),
              expression: a!gridLayoutColumnConfig(width: if(fv!isLast,"ICON","DISTRIBUTE"))
            ),
            rows: a!forEach(
              items: local!data,
              expression: a!gridRowLayout(
                id: fv!index,
                contents: {
                  a!textField(
                    value: fv!item.data1,
                    saveInto: {
                      a!save(local!data[fv!index].data1,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!textField(
                    value: fv!item.data2,
                    saveInto: {
                      a!save(local!data[fv!index].data2,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!textField(
                    value: fv!item.data3,
                    saveInto: {
                      a!save(local!data[fv!index].data3,save!value),
                      a!save(local!dataChanged,true) /* flag dataChanged value */
                    }
                  ),
                  a!imageField(
                    images: a!documentImage(
                      document: a!iconIndicator("REMOVE"),
                      link: a!dynamicLink(
                        value: fv!index,
                        saveInto: {
                          a!save(local!data, remove(local!data, save!value)),
                          a!save(local!dataChanged,true) /* flag dataChanged value */
                        }
                      )
                    ),
                    size: "ICON"
                  )
                }
              )
            ),
            addRowLink: a!dynamicLink(
              label: "Add a Row",
              saveInto: {
                a!save(local!data,append(local!data,local!dataDefault)),
                a!save(local!dataChanged,true) /* flag dataChanged value */
              }
            )
          )
        }
      )
    )

Children
No Data