Hey Everyone ,
I need to display the data in the grid as :
Brasil , India
Nepal
My data looks like .
[Type=[id=1, name=nameabc1], country=[id=Bra, name=Brasil]; [id=Ind, name=India], description=abc];[Type=[id=2, name=nameabc2], country=[id=Nep, name=Nepal], description=Testing def]
The Problem I am facing is on indexing the country column . When I index it , it says the totalcount of grid =2 , but total data for the grid is=3 .Its because when I country column is taking --> [id=Bra, name=Brasil]; [id=Ind, name=India];[id=Nep, name=Nepal] .Instead of , [[id=Bra, name=Brasil]; [id=Ind, name=India]] ; [[id=Nep, name=Nepal]].Any suggestion how I can add those extra "[ ]" , so that I can display the country accordingly . ?????Thanks in advance .
Discussion posts and replies are publicly visible
What version of Appian are you using? Doing this gets significantly easier in versions 19.2 and later, using the new revamped paging grid component.
Can I get some tips . any explanation will be really helpful .
I can't really tell you until you answer my initial question, though.
Mike Schmitt
18.3
Can you post the code you're currently using for your grid? Please use "Insert --> Insert Code" to generate a code box to maintain indentation and preserve readability.
a!gridField( label: "Deal Collateral", labelPosition: "COLLAPSED", totalCount: local!datasubset.totalCount, emptyGridMessage: resource( "No Collateral available" ), columns : { a!gridTextColumn( label: resource("Type"), field: "collateraltype", data: a!forEach( items: local!datasubset, expression: a!forEach( items: fv!item.data, expression: a!forEach( items: fv!item, expression: index( index( fv!item, "Type", null ), "name", null ) ) ) ) ), a!gridTextColumn( label: resource( "Description" ), field: "description", data: a!forEach( items: local!datasubset, expression: a!forEach( items: fv!item.data, expression: a!forEach( items: fv!item, expression: index( fv!item, "description", null ) ) ) ) ), a!gridTextColumn( label: resource( "Count of Country(test)" ), field: "country", data: a!forEach( items: local!datasubset, expression: a!forEach( items: fv!item.data, expression: a!forEach( items: fv!item, expression: a!forEach( items: fv!item, expression: count( fv!item.country ) ) ) ) ) ), a!gridTextColumn( label: resource( "Country" ), field: "country", data: a!forEach( items: local!datasubset, expression: a!forEach( items: fv!item.data, expression: a!forEach( items: fv!item, expression: a!forEach( items: fv!item, expression: a!forEach( items: fv!item.country[1], expression: fv!item ) ) ) ) ) ) }
gives me the table as below :
Brasil
a!foreach(
items: local!datasubset,
expressions : local!datasubset .data
)
Returns: [Type=[id=1, name=nameabc1], country=[id=Bra, name=Brasil]; [id=Ind, name=India], description=abc];[Type=[id=2, name=nameabc2], country=[id=Nep, name=Nepal], description=Testing def]
I am not able to show all the countries as it says the totalcount exceed the number of largest column data .
First, why does each column of your grid call a triple-nested stack of a!forEach calls? That seems like it should be totally unnecessary. For instance, I would think your description column should just be able to use this code:
a!gridTextColumn( label: resource( "Description" ), field: "description", data: a!forEach( items: local!dataSubset, expression: property(fv!item, "description", {}) ) )
As for showing all countries - I expect your problem is that you may have been trying to pass an array of countries back to the grid, which confuses the old grid rendering system as it can't tell the difference between a single array and an array of arrays. You already got a count of countries to work, so to show all countries we just need to go one step further and turn the *array* of countries into a *single string* of countries.
Add this new column to the code you already have and see if it works at all. Once again I've stripped out the seemingly unnecessary multiple layers of a!forEach calls.
a!gridTextColumn( label: resource("List of Country (test)"), data: a!forEach( items: local!datasubset, expression: joinarray( property(fv!item, "country", {}), char(10) /* this will add a linebreak, but you can add whatever separator you want */ ) ) ),
Couldn't thank you more . THanks again though Mike Schmitt . :)