Hi all,
I'm trying to use a single dropdown list to add multiple users to my grid, right now when I Select one it saves it, but if I select the dropdown again it will overwrite my first selection, how can I over come this?
Basically I want to select -> save , select again -> save and so on.
Discussion posts and replies are publicly visible
You probably want your saveInto to append to an array.
a!localVariables( local!value, local!values, { a!dropdownField( label: "Dropdown", placeholder: "Choose value", choiceLabels: { "Value 1", "Value 2", "Value 3" }, choiceValues: { "Value 1", "Value 2", "Value 3" }, value: index(local!value, "name", null), saveInto: { a!save(local!value, a!map(name: save!value)), a!save( local!values, append(local!values, local!value) ) } ), a!gridField( data: local!values, columns: { a!gridColumn(value: fv!row.name) } ) } )
Thanks for answering! ! but since my list of dropwdown is actually a list of data, it gives me this error
Interface Definition: Expression evaluation error at function a!gridField [line 520]: Invalid types, can only act on data of the same type (Text, Any Type)
This is how my choiceValues are : a!forEach( items: local!iusersData, expression: fv!item.Soeid ),
for displaying in the grid
Not much to go on. Would need more details.
the local variable that has my list of values for the dropdown each item in that list is a row of data it has name, id, and email. for the dropdown I'm only showing the name, but when I save the selection into the map it saves eveything 3 times . so for example:
saveInto: { a!save(local!value, a!map(Name:save!value, id: save!value, Email: save!value)), a!save( local!values, append(local!values, local!value) ),
it saves :
name: ana , 7, ana @gmail.com
id: ana , 7, ana @gmail.com
email: ana , 7, ana @gmail.com
a!localVariables( local!choices: { a!map(id: 1, name: "Ana", email: "ana@test.com"), a!map(id: 2, name: "Joe", email: "joe@test.com"), a!map(id: 3, name: "Jane", email: "jane@test.com") }, local!value, local!values, { a!dropdownField( label: "Dropdown", placeholder: "Choose value", choiceLabels: index(local!choices, "name", {}), choiceValues: index(local!choices, "id", {}), value: local!value, saveInto: { local!value, a!save( local!values, append( local!values, index( local!choices, wherecontains( save!value, cast( a!listType(typeof(1)), index(local!choices, "id", {}) ) ) ) ) ) } ), a!gridField( data: local!values, columns: { a!gridColumn(value: fv!row.name) } ) } )
Thank you so much ! it worked ! I appreciate your help,
by any chance do you know what is the best way to add the remove column to this grid? This is what I have but doesn't seem like the best way, it still gives me an erros
a!gridColumn( label: "", value: a!buttonArrayLayout( buttons: a!buttonWidget( icon: "Remove", width: "MINIMIZE", style: "DESTRUCTIVE", saveInto: { value: if(isnotnullorempty(local!gridData[fv!row]), a!iconButton( icon: "remove", altText: "Delete", onClick: a!save( local!gridData, remove(local!gridData, fv!row) ), showWhen: isnotnullorempty(local!gridData[fv!row]) ), null ), }, ) ), )
You can't use buttons in a grid.
a!localVariables( local!choices: { a!map(id: 1, name: "Ana", email: "ana@test.com"), a!map(id: 2, name: "Joe", email: "joe@test.com"), a!map(id: 3, name: "Jane", email: "jane@test.com") }, local!value, local!values, { a!dropdownField( label: "Dropdown", placeholder: "Choose value", choiceLabels: index(local!choices, "name", {}), choiceValues: index(local!choices, "id", {}), value: local!value, saveInto: { local!value, a!save( local!values, append( local!values, index( local!choices, wherecontains( save!value, cast( a!listType(typeof(1)), index(local!choices, "id", {}) ) ) ) ) ) } ), a!gridField( data: local!values, columns: { a!gridColumn(value: fv!row.name), a!gridColumn( width: "ICON", value: a!richTextDisplayField( value: a!richTextIcon( icon: "times", color: "NEGATIVE", link: a!dynamicLink( saveInto: { a!save( local!values, remove( local!values, fv!identifier ) ) } ), linkStyle: "STANDALONE" ) ) ) } ) } )
If this helped, please mark the answer as verified to help others who might have the same question.
It worked! Thank you so much for all the help!