Skip to main content
December 2, 2024
Question

To edit on multiple rows along with functionality

  • December 2, 2024
  • 8 replies
  • 0 views

Hi team,

I have requirement such that user can edit single rows and multiple rows as well and while using pm I'm able to edit single and multiple rows as well but there is another requirement such that while editing user  can only edit 2 columns name as: "Electrical Tilt" and "Comment" but while editing electrical tilt on single or multiple row user has to make sure if combination of these 3 columns: "Shared Antenna", "Transmitter", "Antenna PAFX"  are exactly same on any row then electrical tilt of those rows will automatically gets updated 

I have mentioned the code of edit UI, please let me know what could be the best approach to follow

a!localVariables(
  local!isShowtoSite,
  local!siteDetails: rule!SLS_QRY_getSiteSummaryDetails(siteName: ri!siteId),
  local!data: ri!transmitterDetails,
  local!updatedData: difference(local!data, ri!transmitterDetails),
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!cardLayout(
              contents: a!richTextDisplayField(
                labelPosition: "COLLAPSED",
                value: {
                  a!richTextIcon(color: "ACCENT", icon: "arrow-left")
                },
                showWhen: true,
                align: "CENTER"
              ),
              link: a!startProcessLink(
                processModel: cons!SLS_PM_BACK_TO_VERSION_MANAGEMENT,
                processParameters: {
                  siteId: ri!siteId,
                  versionId: ri!versionId,
                  isShowtoSite: local!isShowtoSite,
                  isShow: false
                }
              ),
              tooltip: "Back To Electrical Tilt",
              shape: "ROUNDED"
            ),
            
          },
          width: "EXTRA_NARROW"
        ),
        
      }
    ),
    a!sectionLayout(
      label: "Electrical Tilt",
      contents: {
        a!gridLayout(
          label: "",
          labelPosition: "ABOVE",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Site", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "FBAND", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Band", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Shared Antenna", align: "CENTER"),
            a!gridLayoutHeaderCell(label: "Transmitter", align: "CENTER"),
            a!gridLayoutHeaderCell(
              label: "Transmitter Status",
              align: "CENTER"
            ),
            a!gridLayoutHeaderCell(
              label: "Antenna PAFX",
              align: "CENTER"
            ),
            a!gridLayoutHeaderCell(
              label: "Electrical Tilt",
              align: "CENTER",
              helpTooltip: "Range should be from -99 to 99."
            ),
            a!gridLayoutHeaderCell(label: "Comment *", align: "CENTER"),
            
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
            
          },
          rows: {
            a!forEach(
              items: local!data,
              expression: a!localVariables(
                local!isEditable: true(),
                a!gridRowLayout(
                  contents: {
                    a!textField(
                      label: "Site",
                      value: index(
                        local!siteDetails,
                        'recordType!{9441efd7-521a-4695-82a7-d661a237c67d}SLS Site Sync.fields.{cc433436-7922-4ef6-8ca6-5ed4c1580901}SLSSiteName',
                        {}
                      ),
                      readOnly: true
                    ),
                    a!textField(
                      label: "F Band",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.relationships.{74faaa4b-1bf8-46dd-9c1d-3319079ec944}bandSync.fields.{c51f3cc4-d265-460c-9304-ce8424789fce}fband'],
                      readOnly: true
                    ),
                    a!textField(
                      label: "Band",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.relationships.{74faaa4b-1bf8-46dd-9c1d-3319079ec944}bandSync.relationships.{b9cfac62-9de0-41f8-a774-5b9cb6eaf786}subBandSync.fields.{4b95a91a-aa36-4f3d-8b0f-7466e8ac54ac}sband'],
                      readOnly: true
                    ),
                    a!textField(
                      label: "Shared Antenna",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{046fc054-603c-45de-9c8f-cd445cd22a5c}sharedMastNumber'],
                      readOnly: true
                    ),
                    a!textField(
                      label: "Transmitter",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{be5f8d46-1e65-44ba-9cbd-aed866941ef8}txId'],
                      readOnly: true
                    ),
                    a!textField(
                      label: "Transmitter Status",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.relationships.{84769e18-446e-4758-b7fe-d281d72ab228}transmitterStatusSync.fields.{f3914d75-4b03-4ec1-a34e-1b1ff897af47}transmitterStatus'],
                      readOnly: true
                    ),
                    a!textField(
                      label: "Antenna PAFX",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.relationships.{3c30cebe-2f4e-451b-9ab3-746818e7f1cc}versionAntennaSync.relationships.{82080e5c-9ebc-49d6-99df-3eeb992a712a}physicalAntennaSync.fields.{80025c1b-2fa5-4c4f-ae47-2a9acbd6d2c3}description'],
                      readOnly: true
                    ),
                    a!integerField(
                      label: "Electrical Tilt",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{a5312671-5aa1-46a8-a244-d36d73910a0f}electricalTilt'],
                      saveInto: {
                        a!save(
                          fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{a5312671-5aa1-46a8-a244-d36d73910a0f}electricalTilt'],
                          save!value
                        )
                      },
                      readOnly: not(local!isEditable),
                      
                    ),
                    a!paragraphField(
                      label: "Comment",
                      value: fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{b7c34245-2c0f-4404-b93f-9d81fd168932}etiltComment'],
                      saveInto: {
                        a!save(
                          fv!item['recordType!{5bcd9424-97e1-4cf7-8c9a-db17184cd421}SLS Transmitter Details Sync.fields.{b7c34245-2c0f-4404-b93f-9d81fd168932}etiltComment'],
                          save!value
                        )
                      },
                      readOnly: not(local!isEditable),
                      required: true(),
                      
                    ),
                    
                  }
                )
              )
            )
          },
          selectionSaveInto: {},
          validations: null,
          shadeAlternateRows: true
        )
      }
    ),
    a!columnsLayout(
      columns: a!columnLayout(
        contents: a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Save",
              confirmHeader: "Are you sure ?",
              submit: true,
              disabled: a!isNullOrEmpty(ri!transmitterDetails),
              style: "OUTLINE",
              validate: true,
              confirmMessage: "Are you sure you want to submit.",
              confirmButtonLabel: "Yes",
              cancelButtonLabel: "No",
              saveInto: {
                a!save(
                  ri!updatedTransmitterDetails,
                  local!updatedData
                ),
                a!save(ri!cancel, false())
              }
            ),
            a!buttonWidget(
              label: "Cancel",
              value: true,
              confirmHeader: "Are you sure you want to Cancel?",
              confirmButtonLabel: "Yes",
              cancelButtonLabel: "No",
              submit: true,
              saveInto: ri!cancel,
              style: "OUTLINE",
              color: "NEGATIVE",
              validate: false
            )
          },
          align: "END"
        ),
        width: "1X"
      )
    )
  }
)

[mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] 

    8 replies

    mathieud0001
    December 2, 2024

    Something like this?

    a!localVariables(
      local!values: {
        a!map(
          id: 1,
          sharedAntenna: "value 1",
          transmitter: "value2",
          antennaPAFX: "value3",
          electricalTile: 4
        ),
        a!map(
          id: 2,
          sharedAntenna: "value 1",
          transmitter: "value2",
          antennaPAFX: "value3",
          electricalTile: 4
        ),
        a!map(
          id: 3,
          sharedAntenna: "value 1",
          transmitter: "value2",
          antennaPAFX: "value3",
          electricalTile: 4
        )
      },
      a!gridLayout(
        headerCells: {
          a!gridLayoutHeaderCell(label: "Shared Antenna"),
          a!gridLayoutHeaderCell(label: "Transmitter"),
          a!gridLayoutHeaderCell(label: "Antenna PAFX"),
          a!gridLayoutHeaderCell(label: "Electrical Tilt ")
        },
        rows: a!forEach(
          items: local!values,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.sharedAntenna,
                saveInto: {
                  fv!item.sharedAntenna,
                  if(
                    and(
                      fv!item.sharedAntenna = fv!item.transmitter,
                      fv!item.sharedAntenna = fv!item.antennaPAFX
                    ),
                    a!save(fv!item.electricalTile, 99),
                    {}
                  )
                }
              ),
              a!textField(
                value: fv!item.transmitter,
                saveInto: {
                  fv!item.transmitter,
                  if(
                    and(
                      fv!item.sharedAntenna = fv!item.transmitter,
                      fv!item.sharedAntenna = fv!item.antennaPAFX
                    ),
                    a!save(fv!item.electricalTile, 99),
                    {}
                  )
                }
              ),
              a!textField(
                value: fv!item.antennaPAFX,
                saveInto: {
                  fv!item.antennaPAFX,
                  if(
                    and(
                      fv!item.sharedAntenna = fv!item.transmitter,
                      fv!item.sharedAntenna = fv!item.antennaPAFX
                    ),
                    a!save(fv!item.electricalTile, 99),
                    {}
                  )
                }
              ),
              a!integerField(
                value: fv!item.electricalTile,
                saveInto: fv!item.electricalTile
              )
            }
          )
        )
      )
    )

    December 2, 2024

    thankyou for responding but my requirement doesn't match with your solution as I dont have to store electrical tilt every time in all those 3 columns but while editing electrial tilt where ever combination of those  3 columns  match exactly in other row then only electrifcal tilt update in those rows else  if either any one column among those 3 columns mismatched electrical tilt would not update for other rows instead update only that row where editing is done 

    you getting my point?

    mikes0011
    Brainy
    December 2, 2024

    Your phrasing makes it difficult to decipher what you're actually after here.  Try adding some more specifics, along with some examples of when the automatic updating WOULD happen versus when it would NOT be expected to happen.

    December 3, 2024

    hi mike

    I have already shared you the code but here in this code all the data is coming from a particular table but user can only edit electrical tilt and comment as well since editing is working well but functionality should be made on interface where electrical tilt column is mentioned

    but when user edit electrical tilt then only electrical tilt has to auto update for all that row when the combination of 3 columns (Shared antenna, Transmitter, Antenna PAFX) is exactly same in any row but here are different version status but when status is "PAST" then no changes will be made either combination is same or not

    editing can be done for single and multiple rows and when you will see the code user has to make sure functionality rule is for all version numbers , if there are 1, 2 3, 4, 5 version numbers and when editing is done on 3 version no. then if combination is same on 1, 2 and 4 versions and version no 4 has "PAST" status then electrical tilt will auto update on  1 and 2 version no only

    mikes0011
    Brainy
    December 3, 2024

    I whipped up this simplified example - in this case only "antenna" and "transmitter" need to match for any given row to be considered a "match", but that can be easily scaled to as many fields as you want.  I use a per-row local variable to track other rows that are currently a match (and an optional debug display of these to appear in the "site id" column when needed), which then determines the behavior of the extra SaveInto found in the "tilt value" save.  I assume you should be able to adapt this pattern to the more intricate details of your use case pretty easily.

    a!localVariables(
      
      local!myList: {
        a!map(
          site: 1,
          antenna: "abc",
          trx: "123",
          tilt: null()
        ),
        a!map(
          site: 2,
          antenna: "xyz",
          trx: "543",
          tilt: null()
        ),
        a!map(
          site: 3,
          antenna: "abc",
          trx: "123",
          tilt: null()
        ),
        a!map(
          site: 4,
          antenna: "qwer",
          trx: "3.14",
          tilt: null()
        ),
        a!map(
          site: 5,
          antenna: "abc",
          trx: "123",
          tilt: null()
        ),
        a!map(
          site: 6,
          antenna: "zxcv",
          trx: "42",
          tilt: null()
        ),
      },
      
      a!sectionLayout(
        label: "test grid",
        contents: {
          a!gridLayout(
            headerCells: {
              a!gridLayoutHeaderCell(label: "site"),
              a!gridLayoutHeaderCell(label: "antenna"),
              a!gridLayoutHeaderCell(label: "transmitter"),
              a!gridLayoutHeaderCell(label: "tilt value"),
            },
            rows: a!forEach(
              local!myList,
              
              a!localVariables(
                local!currentRowRef: fv!item,
                local!matchingRowIndices: a!flatten(a!forEach(
                  local!myList,
                  if(
                    and(
                      local!currentRowRef.site <> fv!item.site,
                      local!currentRowRef.antenna = fv!item.antenna,
                      local!currentRowRef.transmitter = fv!item.transmitter
                    ),
                    fv!index,
                    {}
                  )
                )),
                a!gridRowLayout(
                  id: fv!item.site,
                  contents: {
                    a!richTextDisplayField(
                      value: {
                        fv!item.site,
                        
                        a!richTextItem(
                          /* debug info; comment out this "showWhen" temporarily to display it here */
                          showWhen: false(),
                          size: "SMALL",
                          text: {char(10), "Matching Rows: ", joinarray(local!matchingRowIndices, ", ")}
                        )
                      }
                    ),
                    a!richTextDisplayField(
                      value: fv!item.antenna
                    ),
                    a!richTextDisplayField(
                      value: fv!item.trx
                    ),
                    
                    
                    
                    a!textField(
                      value: fv!item.tilt,
                      saveInto: {
                        fv!item.tilt,
                        if(
                          a!isNotNullOrEmpty(local!matchingRowIndices),
                          a!forEach(
                            local!matchingRowIndices,
                            a!save(
                              local!myList[fv!item].tilt,
                              save!value
                            )
                          ),
                          {}
                        )
                      }
                    )
                  }
                )
              )
            )
          )
        }
      )
    )