Skip to main content
June 21, 2021
Question

Editable Grid - Update Rule Input on Data Change

  • June 21, 2021
  • 5 replies
  • 0 views

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.

5 replies

mikes0011
Brainy
June 21, 2021
The problem is that i cant do an "a!save" of the ri! paramenter

Why not?  What is happening when you try?  Can you post some sample code?

The Expression Guru
June 21, 2021

i generally can do that but there isn't a "data change event" in the "editable data grid". So where i can save the value of the ri|parameter on grid data change?

mikes0011
Brainy
June 21, 2021

In this sort of scenario it's probably better to set the data in the parent interface and pass it down to the child interface if needed, and if your intent is to force the data into a Rule Input to be passed into the process, you can always do your a!save within the Submit button.

The Expression Guru
csteward
June 21, 2021

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 */
          }
        )
      )
    }
  )
)