Team,
I have a requirement where data is coming from database and appearing in editable grid all components in grid have read only set to true , i am using dynamic link to delete and add row.
Delete is fine but when i click on add new row , all fields are read only . I want the new added row to be editable and above one's as read only (with required true in it)
Please suggest
Discussion posts and replies are publicly visible
You will first need to decide how your interface will tell the difference between "just added" items in the Data Array, versus ones that were already there. Perhaps the prior data has a primary key, and the new row does not? In this case, your row elements can simply determine whether the row data has a blank primary key, and set read-only to TRUE only in these cases.
Thank you , do you have any reference which i can use ?
I'm not exactly clear on what you still need, but it's all in the Appian documentaton.
a!localVariables( local!data: { {id: 1, field: "test1"}, {id: 2, field: "test2"} }, a!gridLayout( headerCells: {a!gridLayoutHeaderCell(label: "Test")}, totalCount: count(local!data), rows: a!forEach( items: local!data, expression: a!gridRowLayout( id: fv!index, contents: { a!textField( value: local!data[fv!index].field, saveInto: local!data[fv!index].field, readOnly: not(isnull(local!data[fv!index].id)) ) } ) ), addRowLink: aa!dynamicLink( label: "Add Row", value: {}, saveInto: a!save(local!data,append(local!data,{id: null, field: null})) ) ) )
FWIW, I believe (at least in a big picture / code readability sense) it's better to use "fv!item" rather than "local!data[fv!index]" to address array fields. Sorry if this seems overly picky
a!textField( value: fv!item.field, saveInto: fv!item.field, readOnly: not(isnull(fv!item.id)) )
thank you guys ,i got you point .
Totally correct sir! That was a quick-and-dirty
a!localVariables( local!data: { {id: 1, field: "test1"}, {id: 2, field: "test2"} }, a!gridLayout( headerCells: {a!gridLayoutHeaderCell(label: "Test")}, totalCount: count(local!data), rows: a!forEach( items: local!data, expression: a!gridRowLayout( id: fv!index, contents: { a!textField( value: fv!item.field, saveInto: fv!item.field, readOnly: not(isnull(fv!item.id)) ) } ) ), addRowLink: aa!dynamicLink( label: "Add Row", value: {}, saveInto: a!save(local!data,append(local!data,{id: null, field: null})) ) ) )