Display data from editable grid in one interface to as read only grid in another interface

I have stored data in so many rows for same date in editable grid. Now I am trying to display this data as read only grid in another interface row-wise. But I am getting data of only one row and not all the rows.

The code related is inserted below:

 

a!localVariables(
local!newGridRow: 'type!{urn:com:appian:types}Monitoring_Roster'(),
local!addRow:'type!{urn:com:appian:types}Monitoring_Roster'(),

{
{
a!gridLayout(
label: "Monitoring Roster for: "& text(ri!monitoringDate,"dddd") & " " & ri!monitoringDate,
labelPosition: "ABOVE",
headerCells: {
a!gridLayoutHeaderCell(
label: "Monitoring Slot"
),
a!gridLayoutHeaderCell(
label: "Monitoring In Charge"
),
a!gridLayoutHeaderCell(
label: "Comments"
)
},
columnConfigs: {
a!gridLayoutColumnConfig(
width: "DISTRIBUTE"
)
},
rows: {
a!forEach(
items: local!newGridRow,
expression:
{
a!gridRowLayout(
contents: {

a!textField(
label: "Monitoring Slot",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
choiceLabels: cons!Testing_TIMES,
choiceValues: cons!Testing_TIMES,
readOnly: true(),
value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].monitoringSlot,
searchDisplay: "AUTO",
validations: {}
),
a!textField(
label: "Monitoring In-Charge",
labelPosition: "ABOVE",
readOnly: true(),
value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].monitoringInCharge,
refreshAfter: "UNFOCUS",
validations: {}
),
a!textField(
label: "Comments",
labelPosition: "ABOVE",
readOnly: true(),
value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].comments,
refreshAfter: "UNFOCUS",
validations: {}
)

}
)
}
)
},
showWhen: not(isnull(ri!monitoringDate)),
validations: {},
shadeAlternateRows: true,
spacing: "DENSE",
borderStyle: "STANDARD"
)
},

}
)

It is displaying only single row of editable grid while the 'Testing_Exp1' expression rule is fetching data for all the rows have same date (input date) from the database.

Please help me.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    In your example above it looks like you're just declaring local!newGridRow as an empty instance of your CDT.  What exactly were you expecting to happen?  Is this data being written to a database table from which you could query it when later trying to show it in read-only format?

    As a side note: please use the "Insert" --> "Insert Code" functionality available here to paste lengthy code into a convenient code box which will retain formatting/indentation, as well as prevent a single post or comment from getting overly long.  You should have the ability to edit your original post and do this if you feel like trying that Slight smile

  • Thank you Mike.

    I have Inserted the code as per your suggestion.

    And regarding local!newGridRow, the data is inserting in the 'Monitoring_Roster' CDT through 'Write to Datastore Entity' smart service:

    And using the above query, I want to display the data having 'Monitoring Date' as 23-Feb-2021 as read only grid while the above query is retuning the below output (row having slotId=13):

  • 0
    Certified Lead Developer
    in reply to ayushimittal

    So I see your core issue now.  Basically you're doing a separate query for every cell of your grid.  Also the way you've done this, we would only expect one row to show in your grid, seeing as how you're defining your rows by calling a!forEach() onto the local!newGridRow variable, which would only ever contain one value, so you would only ever see one row in your grid.

    For this I think you need a fundamental re-write of your overall logic.  For starters, your local variables should be querying all applicable rows that you'd want to show, into their own local variable.  Then your grid row definition would need to iterate over this list, not re-query for every cell.  Alternatively you could use the Read-Only Grid component, a!gridField(), if you don't need the functionality contained in the editable grid component here.  Sometimes it's better to use an editable grid with all the rows set as read-only, but in most cases I've found this is a waste of effort.

  • Thank you so much for your help.

    I have achieved it by using 'Read Only Grid'. That is quite easy to implement.

  • +1
    Certified Lead Developer
    in reply to ayushimittal

    Cool.  And if you did want to see what the code might look like for doing it properly in an Editable Grid, consider the following revised example:

    a!localVariables(
      /*local!newGridRow: 'type!{urn:com:appian:types}Monitoring_Roster'(),*/
      /*local!addRow:'type!{urn:com:appian:types}Monitoring_Roster'(),*/
      local!currentRows: rule!Testing_Exp1(ri!monitoringDate),
    
      {
        a!gridLayout(
          label: "Monitoring Roster for: "& text(ri!monitoringDate,"dddd") & " " & ri!monitoringDate,
          labelPosition: "ABOVE",
          headerCells: {
            a!gridLayoutHeaderCell(label: "Monitoring Slot"),
            a!gridLayoutHeaderCell(label: "Monitoring In Charge"),
            a!gridLayoutHeaderCell(label: "Comments")
          },
          columnConfigs: {
            a!gridLayoutColumnConfig(width: "DISTRIBUTE")
          },
          
          rows: {
            a!forEach(
              items: local!currentRows,
              expression: a!gridRowLayout(
                contents: {
                  a!textField(
                    label: "Monitoring Slot",
                    labelPosition: "ABOVE",
                    placeholder: "--- Select a Value ---",
                    choiceLabels: cons!Testing_TIMES,
                    choiceValues: cons!Testing_TIMES,
                    readOnly: true(),
                    value: fv!item.monitoringSlot,
                    /*value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].monitoringSlot,*/
                    searchDisplay: "AUTO",
                    validations: {}
                  ),
                  a!textField(
                    label: "Monitoring In-Charge",
                    labelPosition: "ABOVE",
                    readOnly: true(),
                    value: fv!item.monitoringInCharge,
                    /*value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].monitoringInCharge,*/
                    refreshAfter: "UNFOCUS",
                    validations: {}
                  ),
                  a!textField(
                    label: "Comments",
                    labelPosition: "ABOVE",
                    readOnly: true(),
                    value: fv!item.comments,
                    /*value: rule!Testing_Exp1(ri!monitoringDate)[fv!index].comments,*/
                    refreshAfter: "UNFOCUS",
                    validations: {}
                  )
    
                }
              )
              
            )
          },
          showWhen: not(isnull(ri!monitoringDate)),
          validations: {},
          shadeAlternateRows: true,
          spacing: "DENSE",
          borderStyle: "STANDARD"
        )
      }
    )

  • I have just implemented it and it is working as expected.

    Thank you for correcting issue in my code. I was curious to know my mistake.