Hi All,
On gridRowLayout selection i am populating the selected grid data in local!selectedGridData which has the clientID value for selected row. From this local!selectedGridData, we need to update the clientID value to ri!clientDetails.clientID at selected index on click on button.
Here local!selectedGridData and ri!clientDetails both are of array.
Please help with sample code, so that i will try once.
Thanking you
Discussion posts and replies are publicly visible
Can you clarify:1. Is the selection single select or multi select2. is the client ID field editable or read-only in the grid3. what does the ri! have before the button click? is it already populated with all client details and IDs4. local! will be empty on page load, let's say we have 5 entries in grid and you select the 3rd entry, what's the exact req. here on button click
Hi Vinay,
1. Is the selection single select or multi selectAns: Multi Select2. is the client ID field editable or read-only in the gridAns: read-only in the grid3. what does the ri! have before the button click? is it already populated with all client details and IDsAns: before button click ri!clientDetails will be empty. On click on button, we are populating the below example fields
ri!clientDetails will have array of data like below:
[1]id nullname Testmobile 1234567890ClientID null
[2]id nullname Test2mobile 1234567893ClientID null
[3]id nullname Test3mobile 1234567895ClientID null
[4]id nullname Test4mobile 1234567898ClientID null
[5]id nullname Test5mobile 1234567899ClientID null
4. local! will be empty on page load, let's say we have 5 entries in grid and you select the 3rd entry, what's the exact req. here on button clickAns: local!selectedGridData will be empty on page load, it will be populated based on selection of row. When we select 3rd entry the local!selectedGridData will be populated as below example:
[3]id nullname Test3mobile 1234567895ClientID 1029093978
Thanks
Try this in saveInto for the button:a!forEach( items: local!selectedIndices, expression: a!save( ri!clients[fv!item].clientID, index( local!selectedClients, fv!index, "clientID", null ) ) )If you want, you can try it out my code in a sample interface:
a!localVariables( local!selectedClients, local!items: cast( 'type!{urn:com:appian:types:TS}Test_Clients?list', { { id: 1, name: "Test1", mobile: 123, clientID: 10 }, { id: 2, name: "Test2", mobile: 456, clientID: 20 }, { id: 3, name: "Test3", mobile: 789, clientID: 30 }, { id: 4, name: "Test4", mobile: 1234, clientID: 40 }, { id: 5, name: "Test5", mobile: 12345, clientID: 50 } } ), local!selectedIndices: tointeger({}), a!formLayout( contents: { a!buttonArrayLayout( align: "START", buttons: { a!buttonWidget( label: "Update Local!", value: "Update", saveInto: { a!save( local!selectedClients, index(local!items, local!selectedIndices, null) ) }, disabled: count(local!selectedIndices) = 0 ), a!buttonWidget( label: "Update ri!", value: "Update", saveInto: { a!forEach( items: local!selectedIndices, expression: a!save( ri!clients[fv!item].clientID, index( local!selectedClients, fv!index, "clientID", null ) ) ) }, disabled: count(local!selectedIndices) = 0 ) } ), a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "ID", align: "RIGHT"), a!gridLayoutHeaderCell(label: "Name"), a!gridLayoutHeaderCell(label: "Mobile", align: "RIGHT"), a!gridLayoutHeaderCell(label: "Client ID", align: "RIGHT") }, columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2), a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3) }, rows: a!forEach( items: local!items, expression: { a!gridRowLayout( id: fv!index, contents: { a!integerField( value: fv!item.id, readOnly: true, align: "RIGHT" ), a!textField(value: fv!item.name, readOnly: true), a!integerField( value: fv!item.mobile, readOnly: true, align: "RIGHT" ), a!integerField( value: fv!item.clientID, readOnly: true, align: "RIGHT" ) } ) } ), selectable: true, selectionValue: local!selectedIndices, /* Flatten the selected values so the result is easier to work with */ /* when the select/deselect all option is used in an editable grid */ selectionSaveInto: a!save( local!selectedIndices, a!flatten(save!value) ), rowHeader: 2 ), a!textField( label: "Selected Values", labelPosition: "ADJACENT", instructions: typename(typeof(local!selectedIndices)), value: local!selectedIndices, readOnly: true ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidget(label: "Submit", submit: true) ) ) )
{ { id: null, name: "Test", mobile: 1234567890, ClientID: null }, { id: null, name: "Test2", mobile: 1234567893, ClientID: null }, { id: null, name: "Test3", mobile: 1234567895, ClientID: null }, { id: null, name: "Test4", mobile: 1234567898, ClientID: null }, { id: null, name: "Test5", mobile: 1234567899, ClientID: null } }
Thanks Vinay, logic is working well.