I'm doing some testing with integrations and grid fields within Appian 17.3 and have a question on functionality ...
My integration returns rather a lot of data, lets say 1000 rows and I've coded a grid layout to display the data that is retrieved.
given that it's returning 1000 rows, it's rather slow to display. (the actual integration is quite fast). I've set my totalCount to 10 (totalCount:10), in the hope that it would stop building the grid at 10 rows, but that doesnt seem to happen. Have I mis understood what totalCount is for ?
looking back I should have used a paging grid, but I was also wanting to experiment for the forEach functions ..
Discussion posts and replies are publicly visible
/* Optional Inputs: ---------------- 01. label 02. instructions (Pagination Instructions if the input is null) 03. selectable (False if the input is null) 04. selectionRequired (False if the input is null) 05. selectionDisabled (True if the input is null) 06. selectionValue 07. selectionSaveArray 08. validations 09. validationGroup 10. helpTooltip 11. items 12. emptyGridMessage 13. isValidateWhileNavigation (False if the input is null) 14. firstPageSaveArray 15. lastPageSaveArray 16. nextPageSaveArray 17. previousPageSaveArray Required Inputs: ---------------- 01. headerCells 02. nameOfItemsRowEachRule 03. columnConfigs 04. pagingInfo 05. addRowLinkLabel 06. addRowLinkValue Example: -------- rule!PS_EditableGrid_SAIL_GetEditableGrid( label: "", instructions:null, headerCells: { a!gridLayoutHeaderCell(label: "Summary"), a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"), a!gridLayoutHeaderCell(label: "", align: "RIGHT") }, nameOfItemsRowEachRule: rule!PS_EditableGrid_SAIL_TestUCItemsRowEach, selectable:true, selectionRequired: false, selectionDisabled: false, selectionValue: {}, selectionSaveInto: { local!selectedValues }, validations: null, validationGroup: null, totalCount: length(local!items), columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 5), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE") }, pagingInfo: local!pagingInfo, isValidateWhileNavigation:false, addRowLinkLabel:"Add Item", addRowLinkValue: 'type!{urn:com:appian:types}PS_example1CDT'() ) */ load( /* Length of items array */ local!lengthOfItems: if(fn!isnull(ri!items),0,length(ri!items)), local!itemsToken: ri!items, /* Assign default values to the variables incase if the rule inputs aren't assigned values */ local!isValidateWhileNavigation: rule!COMMON_Util_ReplaceNull( nullableValue: ri!isValidateWhileNavigation, replacementValue: fn!false() ), local!selectionRequired: rule!COMMON_Util_ReplaceNull( nullableValue: ri!selectionRequired, replacementValue: fn!false() ), local!selectionDisabled: rule!COMMON_Util_ReplaceNull( nullableValue: ri!selectionDisabled, replacementValue: fn!true() ), local!selectable: rule!COMMON_Util_ReplaceNull( nullableValue: ri!selectable, replacementValue: fn!false() ), local!instructions: rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ), /* Enable or Disable Navigations */ local!isNextPageNavigationDisabled: (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems, local!isPreviousPageNavigationDisabled: ri!pagingInfo.startIndex = 1, local!isFirstPageNavigationDisabled: ri!pagingInfo.startIndex = 1, local!isLastPageNavigationDisabled: (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems, { /* Editable Grid with Pagination */ a!gridLayout( label: ri!label, instructions: local!instructions, helpTooltip: ri!helpTooltip, totalCount: local!lengthOfItems, emptyGridMessage: ri!emptyGridMessage, columnConfigs: ri!columnConfigs, selectable: local!selectable, selectionRequired: local!selectionRequired, selectionDisabled: local!selectionDisabled, selectionValue: ri!selectionValue, selectionSaveInto: { ri!selectionValue, /* Any additional operations that should be performed upon making selections. This way any rule that invokes this rule can start making their own save operations apart from saving the selected values. */ ri!selectionSaveArray }, addRowLink: a!dynamicLink( label: ri!addRowLinkLabel, value: ri!addRowLinkValue, saveInto: { /* Append to items array */ a!save( ri!items, fn!append(ri!items, save!value) ), /* Append to itemsToken array */ a!save( local!itemsToken, ri!items ), /* Update the length of the items */ a!save( local!lengthOfItems, fn!if(fn!isnull(ri!items),0,fn!length(ri!items)) ), /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo( fn!if( local!lengthOfItems > ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), (fn!quotient(local!lengthOfItems,ri!pagingInfo.batchSize)*ri!pagingInfo.batchSize) + 1, ri!pagingInfo.startIndex ), ri!pagingInfo.batchSize ) ), /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ), validations: ri!validations, validationGroup: ri!validationGroup, headerCells: ri!headerCells, /* NOTE: Make sure that the Grid Row Layout rule has only four parameters namely items, index, itemsToken and removeAdditionalSaveArray. This is a drawback/limitation/constraint. And removeAdditionalSaveArray should be configured in the saveInto of the Delete Operation */ rows: a!applyComponents( ri!nameOfItemsRowEachRule( items:ri!items, index:_, itemsToken:local!itemsToken, removeAdditionalSaveArray: { /* Update the length of the items */ a!save( local!lengthOfItems, fn!if(fn!isnull(ri!items),0,fn!length(ri!items)) ), /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo( fn!if( local!lengthOfItems <= ri!pagingInfo.batchSize, 1, fn!if( rule!COMMON_Util_IsEmpty(data:fn!index(ri!items,enumerate(ri!pagingInfo.batchSize)+ri!pagingInfo.startIndex,null)), ri!pagingInfo.startIndex - ri!pagingInfo.batchSize, ri!pagingInfo.startIndex ) ), ri!pagingInfo.batchSize ) ), /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ), fn!if( local!lengthOfItems=0, {}, ri!pagingInfo.startIndex + fn!if( local!lengthOfItems < ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), fn!enumerate((local!lengthOfItems - ri!pagingInfo.startIndex)+1), fn!enumerate(ri!pagingInfo.batchSize) ) ), local!itemsToken ) ), /* Buttons that help navigating in Grid and also helps in simulating the Pagination functionality */ /* Next Page Navigation */ a!buttonLayout( primaryButtons: { a!buttonWidget( label: ">", style: "NORMAL", confirmMessage: null, submit: fn!false(), disabled: local!isNextPageNavigationDisabled, validate : local!isValidateWhileNavigation, validationGroup: null, value: null, saveInto: { /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo( ri!pagingInfo.startIndex + ri!pagingInfo.batchSize, ri!pagingInfo.batchSize ) ), /* Any additional operations that should be performed upon navigating to next page. This way any rule that invokes this rule can start making its specific save operations apart from default save operations. */ ri!nextPageSaveArray, /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ), /* Last Page Navigation */ a!buttonWidget( label: ">>", style: "NORMAL", confirmMessage: null, submit: fn!false(), disabled: local!isLastPageNavigationDisabled, validate : local!isValidateWhileNavigation, value: null, saveInto: { /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo( ((fn!quotient(local!lengthOfItems,ri!pagingInfo.batchSize)-fn!if(fn!mod(local!lengthOfItems,ri!pagingInfo.batchSize)=0,1,0))*ri!pagingInfo.batchSize) + 1, ri!pagingInfo.batchSize ) ), /* Any additional operations that should be performed upon navigating to last page. This way any rule that invokes this rule can start making its specific save operations apart from default save operations. */ ri!lastPageSaveArray, /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ) }, secondaryButtons: { /* First Page Navigation */ a!buttonWidget( label: "<<", style: "NORMAL", confirmMessage: null, submit: false, disabled: local!isFirstPageNavigationDisabled, validate : local!isValidateWhileNavigation, validationGroup: null, value: null, saveInto: { /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo(1,ri!pagingInfo.batchSize) ), /* Any additional operations that should be performed upon navigating to first page. This way any rule that invokes this rule can start making its specific save operations apart from default save operations. */ ri!firstPageSaveArray, /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ), /* Previous Page Navigation */ a!buttonWidget( label: "<", style: "NORMAL", confirmMessage: null, submit: false, disabled: local!isPreviousPageNavigationDisabled, validate : local!isValidateWhileNavigation, validationGroup: null, value: null, saveInto: { /* Update Paging Info */ a!save( ri!pagingInfo, fn!topaginginfo( ri!pagingInfo.startIndex - ri!pagingInfo.batchSize, ri!pagingInfo.batchSize ) ), /* Any additional operations that should be performed upon navigating to last page. This way any rule that invokes this rule can start making its specific save operations apart from default save operations. */ ri!previousPageSaveArray, /* Enable or Disable Navigations */ a!save( local!isNextPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), a!save( local!isPreviousPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isFirstPageNavigationDisabled, ri!pagingInfo.startIndex = 1 ), a!save( local!isLastPageNavigationDisabled, (ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) > local!lengthOfItems ), /* Update Instructions */ a!save( local!instructions, rule!COMMON_Util_ReplaceNull( nullableValue:ri!instructions, replacementValue:fn!concat(fn!if(local!lengthOfItems=0,0,ri!pagingInfo.startIndex), "-", fn!if(local!lengthOfItems <= ((ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1),local!lengthOfItems,(ri!pagingInfo.startIndex + ri!pagingInfo.batchSize) - 1), " of ", local!lengthOfItems) ) ) } ) } ) } )
Please find the attached document of code