editable grid

A Score Level 1

hi ,

i need to created a grid in which data is coming from a table in DB.

The user can update any column value from that grid. On click of submit , the new column values will be saved into DB.

User should be able to delete a row or any column value from the grid also. Those should also be saved into Db on submit. How to pursue this using editable grid ?

Update 1:

 Grid data is visible , Values are coming from the DB.

 But whenever I try to change any column values , for example producer code , data doesnt persists, same value comes on clicking elsewhere.

Texfiled values are saved into local variable , saveinto is an Ri mapping of that table type . 

Attached the updated Code.

load(
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20,
    sort: a!sortInfo(
      field: "prdcr_cde",
      ascending: false()
    )
  ),
  local!showLink,
  local!tableDetails: rule!APAC_SGP_getProducercodeAHmapDetails(
    pagingInfo: local!pagingInfo
  )a!sectionLayout(
    contents: {
      a!gridLayout(
        label: "",
        headerCells: {
          a!gridLayoutHeaderCell(
            label: "Account Handler User "
          ),
          a!gridLayoutHeaderCell(
            label: "Producer Code",
            
          ),
          a!gridLayoutHeaderCell(
            label: "Is Active",
            
          ),
          a!gridLayoutHeaderCell(
            label: "",
            
          )
        },
        columnConfigs: {
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: 3
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: 3
          ),
          a!gridLayoutColumnConfig(
            width: "DISTRIBUTE",
            weight: 3
          ),
          a!gridLayoutColumnConfig(
            width: "ICON"
          )
        },
        rows: {
          a!forEach(
            items: local!tableDetails,
            expression: a!gridRowLayout(
              contents: {
                a!textField(
                  value:  local!tableDetails[fv!index].ah_id,
                  saveInto:  local!tableDetails[fv!index].ah_id
                ),
                a!textField(
                  value:  local!tableDetails[fv!index].prdcr_cde,
                  saveInto:  local!tableDetails[fv!index].prdcr_cde
                ),
                a!textField(
                  value:  local!tableDetails[fv!index].is_active,
                  saveInto:  local!tableDetails[fv!index].is_active
                ),
                a!imageField(
                  label: "Delete " & fv!index,
                  images: a!documentImage(
                    document: a!iconIndicator(
                      "REMOVE"
                    ),
                    altText: "Remove Data",
                    caption: "Remove ",
                    link: a!dynamicLink(
                      value: fv!index,
                      saveInto: {
                        a!save(
                          local!tableDetails,
                          remove(
                            local!tableDetails,
                            save!value
                          )
                        )
                      }
                    )
                  ),
                  size: "ICON"
                )
              }
            )
          )
        },
        addRowlink: a!dynamicLink(
          label: "Add Rows",
          value: {
            startDate: today() + 1
          },
          saveInto: {
            a!save(
              local!tableDetails,
              append(
                local!tableDetails,
                save!value
              )
            )
          }
        ),
        rowHeader: 1,
        /*showWhen: toboolean(*/
        /*local!showLink*/
        /*) = true(),*/
        
      ),
      a!buttonLayout(
        primaryButtons: {
          a!buttonWidgetSubmit(
            label: cons!APAC_TEXT_ACTIONS[1],
            confirmMessage: "Are you sure you want to submit?",
            value: cons!APAC_TEXT_ACTIONS[1],
            saveInto: {
              ri!buttonAction,
              
            },
            style: "PRIMARY",
            skipValidation: true()
          )
        },
        secondaryButtons: {
          a!buttonWidgetSubmit(
            label: cons!APAC_TEXT_ACTIONS[2],
            value: cons!APAC_TEXT_ACTIONS[2],
            saveInto: ri!buttonAction,
            style: "DESTRUCTIVE",
            skipValidation: true()
          )
        }
      )
    }
  )
)

Ri mapping is of the producer table type and array type.  Kindly help.

  Discussion posts and replies are publicly visible

Parents
  • You would need to call a Process Model or a!writeToDataStoreEntity() in the  saveInto: of the submit button and pass the ri!

  • 0
    A Score Level 1
    in reply to Sikandar

    i have created the process model for that , but the new values that i fill in the grid , those dont update , how can i edit the grid ?

  • In the saveInto you would need to call the Process Model that you created and pass the local!tableDetails using the a!startProcess() 

    one more thing Incase the user deletes the row that is already present in the table you would need to update the isActive to 0.

  • 0
    A Score Level 1
    in reply to Sikandar

    I tried this using the other approach , but my process model isnt getting published due to that.

    load(
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20,
        sort: a!sortInfo(
          field: "prdcr_cde",
          ascending: false()
        )
      ),
      local!selectedRows,
      local!tableDetails: rule!APAC_getproducerDetails(
        pagingInfo: local!pagingInfo
      )a!sectionLayout(
        contents: {
          a!gridLayout(
            label: "",
            headerCells: {
              a!gridLayoutHeaderCell(
                label: "Account Handler User " & local!tableDetails.id & " dfgdhhgdh" & local!selectedRows
              ),
              a!gridLayoutHeaderCell(
                label: "Producer Code",
                
              ),
              a!gridLayoutHeaderCell(
                label: "Is Active",
                
              ),
              a!gridLayoutHeaderCell(
                label: "",
                
              )
            },
            columnConfigs: {
              a!gridLayoutColumnConfig(
                width: "DISTRIBUTE",
                weight: 3
              ),
              a!gridLayoutColumnConfig(
                width: "DISTRIBUTE",
                weight: 3
              ),
              a!gridLayoutColumnConfig(
                width: "DISTRIBUTE",
                weight: 3
              ),
              a!gridLayoutColumnConfig(
                width: "ICON"
              )
            },
            rows: {
              a!forEach(
                items: local!tableDetails,
                expression: a!gridRowLayout(
                  contents: {
                    a!textField(
                      value: local!tableDetails[fv!index].ah_id,
                      saveInto: {
                        local!tableDetails[fv!index].ah_id,
                        a!save(
                          ri!mapping.ah_id,
                          save!value
                        )
                      }
                    ),
                    a!textField(
                      value: local!tableDetails[fv!index].prdcr_cde,
                      saveInto: {
                        local!tableDetails[fv!index].prdcr_cde,
                        a!save(
                          ri!mapping.prdcr_cde,
                          save!value
                        )
                      }
                    ),
                    a!textField(
                      value: local!tableDetails[fv!index].is_active,
                      saveInto: {
                        local!tableDetails[fv!index].is_active,
                        a!save(
                          ri!mapping.is_active,
                          save!value
                        )
                      }
                    ),
                    a!imageField(
                      label: "Delete " & fv!index,
                      images: a!documentImage(
                        document: a!iconIndicator(
                          "REMOVE"
                        ),
                        altText: "Remove Data",
                        caption: "Remove ",
                        link: a!dynamicLink(
                          value: fv!index,
                          saveInto: {
                            a!save(
                              local!selectedRows,
                              local!tableDetails[save!value]
                            ),
                            
                          }
                        )
                      ),
                      size: "ICON"
                    )
                  }
                )
              )
            },
            addRowlink: a!dynamicLink(
              label: "Add Rows",
              value: {
                startDate: today() + 1
              },
              saveInto: {
                a!save(
                  local!tableDetails,
                  append(
                    local!tableDetails,
                    save!value
                  )
                )
              }
            ),
            rowHeader: 1,
            /*showWhen: toboolean(*/
            /*local!showLink*/
            /*) = true(),*/
            
          ),
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidgetSubmit(
                label: cons!APAC_TEXT_ACTIONS[1],
                confirmMessage: "Are you sure you want to submit?",
                value: cons!APAC_TEXT_ACTIONS[1],
                saveInto: {
                  ri!buttonAction,
                  if(
                    isnull(
                      local!selectedRows
                    ),
                    {},
                    a!deleteFromDataStoreEntities(
                      dataToDelete: {
                        entity: cons!APAC_SGP_PC_AH_MAP,
                        identifiers: local!selectedRows.id
                      }
                    )
                  )
                 
                },
                style: "PRIMARY",
                skipValidation: true()
              )
            },
            secondaryButtons: {
              a!buttonWidgetSubmit(
                label: cons!APAC_TEXT_ACTIONS[2],
                value: cons!APAC_TEXT_ACTIONS[2],
                saveInto: ri!buttonAction,
                style: "DESTRUCTIVE",
                skipValidation: true()
              )
            }
          )
        }
      )
    )

    Here I have one delete icon in the grid , i want to delete that particular row/rows which user selects(local! selectedRows) . I am able to add a new row and data into the grid. But publishing the process model gives the error.

    neither variables nor rules found :content

    I chechked online and found this error is due to interface error , but i am not able to detect the issue. 

  • 0
    A Score Level 1
    in reply to ST07

    this is the grid , on clicking cross items (rows)should get deleted  from the DB.

  • 0
    Certified Lead Developer
    in reply to ST07

    I don't have any way of verifying that this is the only issue, but there's a major error in your code here:

    In general when trying to get any interface to work in a task / process model, you need to make sure it's working within interface designer first.  The above typo would keep this code (assuming you copied it 1:1) from working at all.

  • 0
    A Score Level 1
    in reply to Mike Schmitt

    hi , the grid is working , but i am getting error on publishig the process model .

    neither variables nor rules found :content

Reply Children