... local!cart: rule!AS_Get_Cart(), ... a!gridLayout( label: "Editable Grid", labelPosition: "COLLAPSED", headerCells: { a!gridLayoutHeaderCell(label: "Item"), a!gridLayoutHeaderCell( label: "Price" ), a!gridLayoutHeaderCell( label: "Stock" ), a!gridLayoutHeaderCell( label: "Quantity", helpTooltip: "The number of items you want to buy" ), a!gridLayoutHeaderCell( label: "Total Price" ), a!gridLayoutHeaderCell( label: "" ) }, columnConfigs: { a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 4 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 1 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: { { a!forEach( items: local!cart, expression: a!gridRowLayout( contents: { a!textField( label: "item", labelPosition: "ABOVE", value: fv!item.name, saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!floatingPointField( label: "price", labelPosition: "ABOVE", value: fv!item.price, saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!integerField( label: "stock", labelPosition: "ABOVE", value: fv!item.stock, saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!integerField( label: "quantity", labelPosition: "ABOVE", value: fv!item.quantity, saveInto: fv!item.quantity, refreshAfter: "UNFOCUS", required: true, validations: if(fv!item.quantity>fv!item.stock,"Sorry, we dont have those many items in stock",null()) ), a!floatingPointField( label: "TotalPrice", labelPosition: "ABOVE", value: if(isnull(fv!item.quantity),"$0",dollar(tointeger(fv!item.quantity) * todecimal(fv!item.price))), saveInto: fv!item.total, refreshAfter: "UNFOCUS", validations: {} ), a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextIcon( icon: "times", link: a!dynamicLink( label: "Dynamic Link", saveInto: { a!deleteFromDataStoreEntities(dataToDelete: a!entityDataIdentifiers( entity: cons!AS_DataStore_Cart_Pointer, identifiers: fv!item.name )) } ), color: "#ff0000" ) } ) } ))
a!localVariables( local!results: a!queryEntity( entity: cons!AS_DataStore_Cart_Pointer, query: a!query( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 50 ) ), fetchTotalCount: false ).data, cast(typeof('type!{urn:appian:as}AS_Cart_DataBase'()), local!results))
So, I have this query and this snippet but the grid is only displaying the last item introduced in my DB, any hint in whats wrong?
Discussion posts and replies are publicly visible
Hi pedrob0002,
How many items that you can see in your local!cart?
Regards,
Acacio B.
Got it, was missing some curly braces covering the type!
since you're here, do you know of any way I can refresh a variable without using some time event? like on the click of a button
Well using the refreshVariable you have few different ways to refresh your variable (refreshAlways, refreshOnReferencedVarChange, refreshOnVarChange, refreshAfter) depend of what are you trying to achieve
I suggest this format instead:
cast( 'type!{urn:appian:as}AS_Cart_DataBase?list', local!results )
(Note that you need to remove the extra "()" from the end of the type name, or else using the "?list" notation will not work.)
There is also the a!listType() function