data: local!noteData, columns: { a!forEach( items: local!fields, expression: a!gridColumn( label: fv!item, value: index(fv!row, fv!item, "") ) ) },
How do I convert the above code, this part:
expression: a!gridColumn( label: fv!item, value: index(fv!row, fv!item, "") )
To something like:
a!gridColumn(label: "Note",value: index(fv!row, "Note", "")),
a!gridColumn(label: "Name",value: index(fv!row, Name, ""))
Where both Note and Name are keys in a dictionary.
Thanks
Discussion posts and replies are publicly visible
You probably want to use the a!keys() function. Here's an example:
a!localVariables( local!data: { a!map(note: "Sample Note", name: "Sample Name"), a!map(note: "Sample Note 2", name: "Sample Name 2"), }, a!gridField( data: local!data, columns: a!forEach( items: a!keys(index(local!data, 1, {})), expression: a!gridColumn( label: fv!item, value: index(fv!row, fv!item, "") ) ) ) )
However, by using the Keys function I get all of the keys, which I do not want.Using your example I've added a description key, I do not want that key to be displayed.In the local!data I also have the primary key value for the record, not too useful fore the end user either.
a!localVariables( local!data: { a!map(note: "Sample Note", name: "Sample Name", description: "i am a description"), a!map(note: "Sample Note 2", name: "Sample Name 2", description: ""), }, a!gridField( data: local!data, columns: a!forEach( items: a!keys(index(local!data, 1, {})), expression: a!gridColumn( label: fv!item, value: index(fv!row, fv!item, "") ) ) ) )
That's fair, but if you're explicitly choosing certain fields, I think it's easier to just define them yourself. Instead of using a!keys, just put a list with the fields you plan to display.
petel0001 said:by using the Keys function I get all of the keys, which I do not want.
There was no way of telling this was a constraint from your original post. Therefore it might be better if you actually talk about your requirements in general, instead of posting a short snippet with no context and expecting us to guess at the details you didn't happen to share originally.