totalCount not working ??

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

  • 0
    Certified Lead Developer
    You should set the "batchSize" to 10 in your a!pagingInfo() instead of the total count.
  • 0
    Certified Lead Developer
    in reply to pauls985
    Appian best practice says if you're retrieving a large dataset that's read-only and no actions need to be taken then you should use a!gridField() instead of a!gridLayout().
  • totalCount is used to indicate the total number of rows of data represented in the grid...make sure you convert your data to a datasubset, then using pagingInfo as recommened by Jamal Case to page thru the data.
  • Here paging grid is better option than a!gridLayout(), but we can also use paginginfo in a!gridLayout() for divide the data in chunks.

  • 0
    Certified Lead Developer
    in reply to ankita0004
    Can you share your code. I’m curious to see this implementation.
  • 0
    A Score Level 1
    in reply to Jamal Case

    load(
    	local!pagingInfo: topaginginfo(1,5),
    	local!items :{
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:1,text_txt:"Lorem Ipsum1"),
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:2,text_txt:"Lorem Ipsum2"),
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:3,text_txt:"Lorem Ipsum3"),
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:4,text_txt:"Lorem Ipsum4"),
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:5,text_txt:"Lorem Ipsum5"),
    		'type!{urn:com:appian:types}PS_example1CDT'(number_int:6,text_txt:"Lorem Ipsum6")
    	},
    	local!itemsToken: local!items,
    	local!selectedValues:{1,2,3,6,7},
    	a!sectionLayout_17r1(
    		label:"Paginated Editable Grid",
    		firstColumnContents:{
    			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: local!selectedValues,
    		selectionSaveInto: {
    		  local!selectedValues
    		},
    		validations: null,
    		validationGroup: null,
    		items:local!items,
    		itemsToken:local!itemsToken,
    		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(
    	a!gridRowLayout(
      id: ri!index,
      contents: {
        a!textField(
          label: "summary " & ri!index,
          readOnly:true(),
          value: ri!items[ri!index].text_txt,
          saveInto: {
    		ri!items[ri!index].text_txt
    	  },
          required: true
        ),
        a!integerField(
          label: "qty " & ri!index,
          readOnly:true(),
    	  value: ri!items[ri!index].number_int,
          saveInto: {
    		ri!items[ri!index].number_int
    	  },
          align: "RIGHT"
        ),
        a!imageField( 
          label: "delete " & ri!index,
          images: a!documentImage(
            document: a!iconIndicator("REMOVE"),
            altText: "Remove",
            caption: "Remove " & ri!items[ri!index].number_int,
            link: a!dynamicLink(
              value: ri!index,
              saveInto: {
                a!save(ri!items, remove(ri!items, save!value)),
                a!save(ri!itemsToken, remove(ri!itemsToken, save!value)),
    			ri!removeAdditionalSaveArray
              }
            )
          ),
          size: "ICON"
        )
      }
    )
    )

    I have attached code for this implementations.

    Let me know if there is any problem to understand the code

  • You are trying to fetch 1000 rows and definately gridLayount is not a good option. Try using Paging grid which is a better design option. Also, gridLayout supports pagingInfo.
  • 0
    Certified Lead Developer
    in reply to ankita0004

     Can you share your code for the "PS_EditableGrid_SAIL_GetEditableGrid" rule? I know a!gridLayout() doesn't have a pagingInfo parameter so I want to see how your using it in your implementation since I see it's being passed into that rule.

  • 0
    A Score Level 1
    in reply to vijayd
    Yes vijay but we can fetch data on based of batchsize so it can be also a good approach.