Hi Experts, I m trying to use editable grid in one of the interface. and i m using pagination to display 15 rows per page. If i select the first row in first page automatically first row in second page gets selected. Below is my code.
a!localVariables( local!allSimulationResults: a!defaultValue( value: ri!allSimulationResults, default: rule!TTPK_qr_getStimulationResults( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 100, sort: a!sortInfo( field: 'recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{75f01d70-8ffd-470f-9028-21ec78222492}simulationId', ascending: false() ) ), masterPartId: ri!masterPartId, fields: { 'recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.relationships.{8f2cd62f-1770-41a8-8106-2103b984e501}ttpkRDocument.fields.{b86f3162-9d59-465a-b496-a6d9f8db3178}appianDocId' }, isFilterReportUrl: true() ) ), local!selectedIdentifier,
local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 15, sort:{ a!sortInfo( field: 'recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{13ea988f-96f7-44a7-8cde-45b221fa4d90}fillRate', ascending: false() )} ), local!dataSubset: todatasubset( local!allSimulationResults, local!pagingInfo ), { a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: { 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{222f9929-748c-420f-afe1-fba3490343b8}Simulation List' }, size: "SMALL", style: "STRONG" ) }, marginAbove: "STANDARD" ), a!horizontalLine(marginAbove: "NONE", marginBelow: "LESS"), a!cardLayout( contents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{87016899-af6e-4792-8e86-c18bd36cadc6}Packaging Code' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{7dcbf5c7-05d7-43d6-9e1e-80c615883654}Packaging Quantity' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{555cf97e-b4bc-469f-9249-cef695cdcdd2}Total Weight' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{52bc8dde-2562-48c8-93b7-4eeb9d986188}Density' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{cd378d53-5952-4aa5-9013-422256146ba0}Packaging Type' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{c62843c0-168c-444e-9cb4-a1f402773c01}Packaging Concept Type' ), a!gridLayoutHeaderCell( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{d08d5947-b674-40d1-90d2-2c190f37a633}Concept Source' ) }, columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE") }, rows: a!forEach( items: local!dataSubset.data, expression: { a!gridRowLayout( /*id: fv!ite,*/ contents: { a!textField( /* Labels are not visible in grid cells but are necessary to meet accessibility requirements */ label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{87016899-af6e-4792-8e86-c18bd36cadc6}Packaging Code' & fv!index, value: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{0b5cdd32-eeec-44d7-82ee-94ac734cc4af}packagingCode'], readOnly: true ), a!integerField( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{7dcbf5c7-05d7-43d6-9e1e-80c615883654}Packaging Quantity' & fv!index, value: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{6a745fa9-73ad-4079-9700-762a6e7947db}quantity'], readOnly: true ), a!integerField( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{555cf97e-b4bc-469f-9249-cef695cdcdd2}Total Weight' & fv!index, value: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{35ca2907-1c33-4767-be6a-f46babfb9a06}totalWeight'], readOnly: true ), a!floatingPointField( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{52bc8dde-2562-48c8-93b7-4eeb9d986188}Density' & fv!index, value: a!defaultValue( value: if( a!isNullOrEmpty( fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{13ea988f-96f7-44a7-8cde-45b221fa4d90}fillRate'] ), null(), fixed( fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{13ea988f-96f7-44a7-8cde-45b221fa4d90}fillRate'], 2 ) ), default: if( a!isNullOrEmpty( fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{6a745fa9-73ad-4079-9700-762a6e7947db}quantity'] ), null(), a!localVariables( local!fillRate: rule!TTPK_calculateFillRate( quantity: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{6a745fa9-73ad-4079-9700-762a6e7947db}quantity'], packagingCode: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{0b5cdd32-eeec-44d7-82ee-94ac734cc4af}packagingCode'] ), if( a!isNullOrEmpty(local!fillRate), null(), fixed(local!fillRate, 2) ) ) ) ), readOnly: true ), a!dropdownField( choiceLabels: cons!TTPK_TXT_PACKAGE_TYPE, choiceValues: cons!TTPK_TXT_PACKAGE_TYPE, label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{cd378d53-5952-4aa5-9013-422256146ba0}Packaging Type' & fv!index, placeholder: "Select Packaging Type", value: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{9cd8a766-a057-4b35-aa23-4558a6ee66b2}packageType'], saveInto: { fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{9cd8a766-a057-4b35-aa23-4558a6ee66b2}packageType'], a!save( ri!finalizedResults, local!dataSubset.data ) }, required: if( contains( tointeger(local!selectedIdentifier), fv!index ), true(), false() ), requiredMessage: "Please select Packaging Type", ), a!textField( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{c62843c0-168c-444e-9cb4-a1f402773c01}Packaging Concept Type' & fv!index, value: a!defaultValue( value: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{dfd9903b-23dd-4716-9d71-fbd33ca1a89a}packagingConceptType'], default: "System Generated" ), readOnly: true ), a!richTextDisplayField( label: 'translation!{4813a583-da1f-481b-adb1-124a9b27e0a6}TTPK Translations.{d08d5947-b674-40d1-90d2-2c190f37a633}Concept Source' & fv!index, value: a!richTextItem( text: if( a!isNullOrEmpty( index( fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.relationships.{8f2cd62f-1770-41a8-8106-2103b984e501}ttpkRDocument.fields.{b86f3162-9d59-465a-b496-a6d9f8db3178}appianDocId'], 1, null() ) ), "NA", "Simulation" ), link: a!documentDownloadLink( showWhen: a!isNotNullOrEmpty( index( fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.relationships.{8f2cd62f-1770-41a8-8106-2103b984e501}ttpkRDocument.fields.{b86f3162-9d59-465a-b496-a6d9f8db3178}appianDocId'], 1, null() ) ), document: fv!item['recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.relationships.{8f2cd62f-1770-41a8-8106-2103b984e501}ttpkRDocument.fields.{b86f3162-9d59-465a-b496-a6d9f8db3178}appianDocId'] ), linkStyle: "STANDALONE" ) ) } ) } ), selectionValue: local!selectedIdentifier, /* 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!selectedIdentifier, a!flatten(save!value) ), /*a!save(*/ /*local!selectedValue,*/ /*index(*/ /*local!dataSubset.data,*/ /*local!selectedIdentifier,*/ /*""*/ /*)*/ /*),*/ a!save( ri!finalizedResults, a!forEach( items: local!dataSubset.data, expression: if( contains( tointeger(local!selectedIdentifier), fv!index ), a!update( fv!item, 'recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{239ecb69-c8a7-4b22-8bfa-d1ec32258da5}hasFinalised', true() ), a!update( fv!item, 'recordType!{e83a3f8a-90c8-4c42-8266-42768da543b9}TTPK_r_simulationResult.fields.{239ecb69-c8a7-4b22-8bfa-d1ec32258da5}hasFinalised', false() ) ) ) ), a!save( local!dataSubset, a!update( local!dataSubset, "data", ri!finalizedResults ) ) }, selectable: true, selectionStyle: "ROW_HIGHLIGHT", validations: { if( a!isNotNullOrEmpty(local!selectedIdentifier), {}, "Please select a value" ) }, rowHeader: 2 ), a!cardLayout( contents: { a!sideBySideLayout( items: { a!sideBySideItem( item: a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextIcon( icon: "exclamation-triangle", color: "#ffc13e", size: "MEDIUM" ) } ), width: "MINIMIZE" ), a!sideBySideItem( /* Replace this rich text with your warning message */ item: a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: if( ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] = cons!TTPK_TXT_STIMULATION_STATUS[2], "Simulation Request In-Progress.", "Simulation Failed. " ), style: "STRONG" ), " ", if( ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] = cons!TTPK_TXT_STIMULATION_STATUS[2], "RPA is processing the simulation request", "Please " ), a!richTextItem( showWhen: ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] = cons!TTPK_TXT_STIMULATION_STATUS[4], text: "click here ", link: a!safeLink( showWhen: ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] = cons!TTPK_TXT_STIMULATION_STATUS[4], uri: "mailto:" & cons!TTPK_TXT_SUPPORT_MAILBOX & "?subject=" & cons!TTPK_TXT_MAIL_SUBJECT & " " & ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{67bb4e85-e8ab-4265-bcc5-35720a42bdac}simulationReqId'], label: "Click here to send email" ) ), if( ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] = cons!TTPK_TXT_STIMULATION_STATUS[2], " ", " to contact support administrator." ), " " } ) ) }, alignVertical: "MIDDLE", spacing: "STANDARD" ) }, showWhen: contains( { cons!TTPK_TXT_STIMULATION_STATUS[2], cons!TTPK_TXT_STIMULATION_STATUS[4] }, tostring( ri!simulationRequest['recordType!{063c5a46-7fee-4b70-9834-c6f389aa2a95}TTPK_r_simulationReq.fields.{f220eda0-59a9-42e7-8de7-2ec304afcc82}singlePartSimulationStatus'] ) ), style: "WARN", marginBelow: "STANDARD" ), a!richTextDisplayField( value: if( local!dataSubset.totalCount <= 15, a!richTextItem( text: concat( local!dataSubset.totalCount, " ", "items" ), style: "STRONG" ), { a!richTextIcon( icon: "chevron-left", link: a!dynamicLink( saveInto: a!save( local!pagingInfo, a!pagingInfo( startIndex: local!pagingInfo.startIndex - local!pagingInfo.batchSize, batchSize: local!pagingInfo.batchSize ) ), showWhen: local!pagingInfo.startIndex > 1 ), linkStyle: "STANDALONE" ), a!richTextItem( text: { char(32), a!richTextItem( text: { joinarray( { property(local!pagingInfo, "startIndex"), char(45), property(local!pagingInfo, "startIndex") + property(local!pagingInfo, "batchSize") - 1 }, char(32) ) }, style: "STRONG" ), char(32), joinarray( { "of", count(local!allSimulationResults) }, char(32) ), char(32) } ), a!richTextIcon( icon: "chevron-right", link: a!dynamicLink( saveInto: a!save( local!pagingInfo, a!pagingInfo( startIndex: local!pagingInfo.startIndex + local!pagingInfo.batchSize, batchSize: local!pagingInfo.batchSize ) ), showWhen: local!pagingInfo.startIndex < count(local!allSimulationResults) - local!pagingInfo.batchSize ), linkStyle: "STANDALONE" ) } ), showWhen: a!isNotNullOrEmpty(local!allSimulationResults), align: "RIGHT" ) }, showBorder: false() ) })
Discussion posts and replies are publicly visible
Hi reenab0003
Insert your code using this :
and can you provide the output of the local!allSimulationResults
Hi reenab0003 ,First and foremost thing, Please dont use AI generated Appian code to write logics, they are inconsistent.Always ensure the selection is specific to the current page and stored correctly for each page.
Right now, the pagination might be resetting or conflicting with the selected row index.I think your selection logic is not working as expected.Please provide some images to help us understand.
Hi reenab0003 , It's better to always provide your code using Insert → Code.
Is your issue resolved? If not, please try modifying the code you wrote for the selected identifier.
Hi The issue is in the ID parameter of gridRowLayout, you have not provided anything so by default it is considering the index you should provide the unique identifier here. In your case you should provide the primary key of your record.
It better to always provide primary key instead of fv!index for grid selection.