Hello,
Is there a possible way to add rownum column in readonly grid?
If possible, it would be appreciated if you could attach an example for reference.
Thank you.
Discussion posts and replies are publicly visible
Hey please find the attached code. You can use fv!identifier for the same.
a!localVariables( local!data: { { a: 1, b: 2, c: 3 }, { a: 4, b: 5, c: 6 }, { a: 7, b: 8, c: 9 }, { a: 10, b: 11, c: 12 }, { a: 13, b: 14, c: 15 } }, a!gridField( data: local!data, columns: { a!gridColumn(value: fv!identifier), a!gridColumn(label: "A", value: fv!row.a), a!gridColumn(label: "B", value: fv!row.a), a!gridColumn(label: "C", value: fv!row.a) } ) )
When you fetch the data from DB, fv!identifier will contain the values from the primary key column.
You could generate a list of number using the enumerate() function and use this as the value of a gridColumn. You might have to consider paging and create this list of numbers with a dynamic offset based on the paging info.
But before diving into this, what is your use case?
That's right, fv!identifier retrieves the value of the primary key column, so not suite for rownum use.
I'm using read-only grid with record type as its data source.
I want to know more about generating a list of number using the enumerate() function, could you provide any example code for it?
Thank you. Always wish the best for you.
What exactly do you want to know about enumerate() besides what can be found in the documentation?
How to add an offset? 42 + enumerate(10) -> 42, 43, 44, 45 ...
enumerated value shows up in th e read-only grid lik [ 1; 2; 3; ].
How can I make it show one number for each row?
(Data source for the read-only grid is record type.)
do you have your code available to post it here? its easier to correct than a picture. but i seems like you are inserting the local instead of fv!row/fv!Item
While this is becoming complicated and I really suggest to push back this requirement, an option might be to update the identifiers field of your datasubset to the above mentioned enumeration. Then you can just use fv!identifier.
Check this untested code you will have to adapt to your needs.
a!update(local!yourDatasubset, "identifiers", local!pagingInfo.startIndex + enumerate(local!pagingInfo.batchSize))
a!localVariables( local!pInfo: a!pagingInfo(10, 10), local!data: a!dataSubset( startIndex: local!pInfo.startIndex, batchSize: local!pInfo.batchSize, totalCount: 100, data: a!forEach( items: enumerate(10), expression: a!map(value: char(fv!index + 60)) ), ), { a!gridField( label: "Read-only Grid", labelPosition: "ABOVE", data: a!update( data: local!data, index: "identifiers", value: local!data.startIndex + enumerate(local!data.batchSize) ), pagingSaveInto: local!pInfo, columns: { a!gridColumn( label: "Grid Column", value: fv!identifier ), a!gridColumn( label: "Grid Column", value: fv!row.value ), }, validations: {} ) } )