Editable Grid Problem

Hi all,

Could somebody tell me what is wrong with this code:

 

a!gridLayout(
 totalCount: count(local!data),
 headerCells: {
   a!gridLayoutHeaderCell(label: "Datum" ),
   a!gridLayoutHeaderCell(label: "Oznaka" ),
   a!gridLayoutHeaderCell(label: "Sreden" ),
   a!gridLayoutHeaderCell(label: "DrzavaAng" ),
   a!gridLayoutHeaderCell(label: "NazivAng" ),
   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: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
   a!gridLayoutColumnConfig(width: "ICON")
 },
 rows: a!forEach(
   items: local!data,
   expression: a!gridRowLayout(
     id: fv!index,
     contents: {
       a!textField(
         label: "Datum "& fv!index ,
         value: fv!item.Datum,
         saveInto: fv!item.Datum,
         required: true
       ),
       a!textField(
         label: "Oznaka " & fv!index,
         value: fv!item.Oznaka,
         saveInto: fv!item.Oznaka,
         required:true
       ),
       a!textField(
         label: "Sreden" & fv!index,
         value: fv!item.Sreden,
         saveInto: fv!item.Sreden,
         required:true
       ),
       a!textField(
         label: "DrzavaAng" & fv!index,
         value: fv!item.DrzavaAng,
         saveInto: fv!item.DrzavaAng,
         required:true
       ),
       a!textField(
         label: "Naziv Ang." & fv!index,
         value: fv!item.NazivAng,
         saveInto: fv!item.NazivAng,
         required:true
       ),
       a!imageField(
                label: "delete " & fv!index,
                images: a!documentImage(
                  document: a!iconIndicator("REMOVE"),
                  altText: "Remove Entry",
                  caption: "Remove " & fv!item.Oznaka,
                  link: a!dynamicLink(
                    value: fv!index,
                    saveInto: {
                      a!save(local!data, remove(local!data, save!value))
                    }
                  )
                ),
                size: "ICON"
              )
     }
   ),
   addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
     a!save(local!data, append(local!data, save!value))
    }
 )
)

 

The error on test that it generated, when I add new row is :

 

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 102]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dateTimeField [line 107]: Invalid index: Cannot index property 'Datum' of type Text into type DataSubset

 

And when I try to remove it remove the whole table with the Remove Icon on the first row.

 

Thanks in advance,Natasa

 

 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer
    Hi Natasa ,

    Can you please try the following code.

    load(
    local!paging: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
    field: "Datum",
    ascending: true
    )
    ),
    local!data: with(
    local!data,
    todatasubset(
    ri!Echange_rate_table,
    local!paging
    )
    ),
    local!documentsToken,
    local!oldAttachments: if(
    or(
    isnull(
    ri!documents
    ),
    count(
    ri!documents
    ) < 1
    ),
    0,
    length(
    ri!documents
    )
    ),
    a!formLayout(
    label: "PoC Start Form",
    instructions: "",
    contents: {
    a!sectionLayout(
    label: "PoC Input data",
    contents: {},
    iscollapsible: true
    ),
    a!sectionLayout(
    label: "Echange rate table",
    contents: {
    a!gridLayout(
    totalCount: count(
    local!data
    ),
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "Datum"
    ),
    a!gridLayoutHeaderCell(
    label: "Oznaka"
    ),
    a!gridLayoutHeaderCell(
    label: "Sreden"
    ),
    a!gridLayoutHeaderCell(
    label: "DrzavaAng"
    ),
    a!gridLayoutHeaderCell(
    label: "NazivAng"
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    )
    },
    rows: a!forEach(
    items: local!data,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    a!dateTimeField(
    label: "Datum " & fv!index,
    value: fv!item.Datum,
    saveInto: fv!item.Datum,
    required: true()
    ),
    a!textField(
    label: "Oznaka " & fv!index,
    value: fv!item.data.Oznaka,
    saveInto: fv!item.data.Oznaka,
    required: true()
    ),
    a!floatingPointField(
    label: "Sreden" & fv!index,
    value: fv!item.data.Sreden,
    saveInto: fv!item.data.Sreden,
    required: true()
    ),
    a!textField(
    label: "DrzavaAng" & fv!index,
    value: fv!item.data.DrzavaAng,
    saveInto: fv!item.data.DrzavaAng,
    required: true()
    ),
    a!textField(
    label: "NazivAng" & fv!index,
    value: fv!item.data.NazivAng,
    saveInto: fv!item.data.NazivAng,
    required: true()
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
    a!save(
    local!data,
    append(
    local!data,
    save!value
    )
    )
    }
    )
    )
    }
    ),
    a!sectionLayout(
    label: "Documents",
    contents: a!gridLayout(
    label: "Attachments",
    emptyGridMessage: "No files have been attached to this record",
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "File"
    ),
    a!gridLayoutHeaderCell(
    label: "Uploaded On",
    align: "RIGHT"
    ),
    a!gridLayoutHeaderCell(
    showWhen: or(
    isnull(
    ri!readOnly
    ),
    not(
    ri!readOnly
    )
    )
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    weight: 7
    ),
    a!gridLayoutColumnConfig(
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "ICON",
    showWhen: or(
    isnull(
    ri!readOnly
    ),
    not(
    ri!readOnly
    )
    )
    )
    },
    rows: a!forEach(
    items: ri!documents,
    expression: rule!PQ_AttachmentsGridRow(
    attachment: fv!item,
    index: fv!index,
    attachments: ri!documents,
    target: ri!target,
    readOnly: ri!readOnly,
    oldAttachments: local!oldAttachments,
    deletedAttachments: ri!deletedDocuments
    )
    ),
    showWhen: or(
    not(
    ri!readOnly
    ),
    and(
    not(
    isnull(
    ri!documents
    )
    ),
    count(
    ri!documents
    ) > 0
    )
    ),
    addRowLink: if(
    ri!readOnly,
    null,
    a!dynamicLink(
    label: "Attach New File",
    value: todocument(
    null
    ),
    saveInto: a!save(
    ri!documents,
    append(
    ri!documents,
    save!value
    )
    )
    )
    )
    )
    ),
    a!sectionLayout(
    label: "Process History",
    contents: {},
    iscollapsible: true
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit",
    value: true(),
    saveInto: ri!cancel,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidgetSubmit(
    label: "Cancel",
    value: false(),
    saveInto: ri!cancel,
    style: "NORMAL",
    skipValidation: true
    )
    }
    ),
    validations: {}
    )
    )


    Thanks,
    Pavani
Reply
  • 0
    Certified Associate Developer
    Hi Natasa ,

    Can you please try the following code.

    load(
    local!paging: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
    field: "Datum",
    ascending: true
    )
    ),
    local!data: with(
    local!data,
    todatasubset(
    ri!Echange_rate_table,
    local!paging
    )
    ),
    local!documentsToken,
    local!oldAttachments: if(
    or(
    isnull(
    ri!documents
    ),
    count(
    ri!documents
    ) < 1
    ),
    0,
    length(
    ri!documents
    )
    ),
    a!formLayout(
    label: "PoC Start Form",
    instructions: "",
    contents: {
    a!sectionLayout(
    label: "PoC Input data",
    contents: {},
    iscollapsible: true
    ),
    a!sectionLayout(
    label: "Echange rate table",
    contents: {
    a!gridLayout(
    totalCount: count(
    local!data
    ),
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "Datum"
    ),
    a!gridLayoutHeaderCell(
    label: "Oznaka"
    ),
    a!gridLayoutHeaderCell(
    label: "Sreden"
    ),
    a!gridLayoutHeaderCell(
    label: "DrzavaAng"
    ),
    a!gridLayoutHeaderCell(
    label: "NazivAng"
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "DISTRIBUTE",
    weight: 3
    )
    },
    rows: a!forEach(
    items: local!data,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    a!dateTimeField(
    label: "Datum " & fv!index,
    value: fv!item.Datum,
    saveInto: fv!item.Datum,
    required: true()
    ),
    a!textField(
    label: "Oznaka " & fv!index,
    value: fv!item.data.Oznaka,
    saveInto: fv!item.data.Oznaka,
    required: true()
    ),
    a!floatingPointField(
    label: "Sreden" & fv!index,
    value: fv!item.data.Sreden,
    saveInto: fv!item.data.Sreden,
    required: true()
    ),
    a!textField(
    label: "DrzavaAng" & fv!index,
    value: fv!item.data.DrzavaAng,
    saveInto: fv!item.data.DrzavaAng,
    required: true()
    ),
    a!textField(
    label: "NazivAng" & fv!index,
    value: fv!item.data.NazivAng,
    saveInto: fv!item.data.NazivAng,
    required: true()
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Entry",
    saveInto: {
    a!save(
    local!data,
    append(
    local!data,
    save!value
    )
    )
    }
    )
    )
    }
    ),
    a!sectionLayout(
    label: "Documents",
    contents: a!gridLayout(
    label: "Attachments",
    emptyGridMessage: "No files have been attached to this record",
    headerCells: {
    a!gridLayoutHeaderCell(
    label: "File"
    ),
    a!gridLayoutHeaderCell(
    label: "Uploaded On",
    align: "RIGHT"
    ),
    a!gridLayoutHeaderCell(
    showWhen: or(
    isnull(
    ri!readOnly
    ),
    not(
    ri!readOnly
    )
    )
    )
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(
    weight: 7
    ),
    a!gridLayoutColumnConfig(
    weight: 3
    ),
    a!gridLayoutColumnConfig(
    width: "ICON",
    showWhen: or(
    isnull(
    ri!readOnly
    ),
    not(
    ri!readOnly
    )
    )
    )
    },
    rows: a!forEach(
    items: ri!documents,
    expression: rule!PQ_AttachmentsGridRow(
    attachment: fv!item,
    index: fv!index,
    attachments: ri!documents,
    target: ri!target,
    readOnly: ri!readOnly,
    oldAttachments: local!oldAttachments,
    deletedAttachments: ri!deletedDocuments
    )
    ),
    showWhen: or(
    not(
    ri!readOnly
    ),
    and(
    not(
    isnull(
    ri!documents
    )
    ),
    count(
    ri!documents
    ) > 0
    )
    ),
    addRowLink: if(
    ri!readOnly,
    null,
    a!dynamicLink(
    label: "Attach New File",
    value: todocument(
    null
    ),
    saveInto: a!save(
    ri!documents,
    append(
    ri!documents,
    save!value
    )
    )
    )
    )
    )
    ),
    a!sectionLayout(
    label: "Process History",
    contents: {},
    iscollapsible: true
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit",
    value: true(),
    saveInto: ri!cancel,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidgetSubmit(
    label: "Cancel",
    value: false(),
    saveInto: ri!cancel,
    style: "NORMAL",
    skipValidation: true
    )
    }
    ),
    validations: {}
    )
    )


    Thanks,
    Pavani
Children
No Data