How to show serial numbers in datagrid or list view? Is there any built-in option available in these widgets to show serial numbers along with rows? If not then what is most efficient way to implement it? Consider a dataset of 100,000 rows, now how can we add serial numbers to it. - Is there any way to just display serials in view and not store it in database? - Should it be done by adding a ‘serialNo’ attribute to the entity? - Stored attribute or calculated attribute? - How to adjust serial numbers when a row is deleted? - How to add serial numbers to newly created data? - How to add functionality to move rows up or down? In this case serial numbers should be adjusted according to the new row positions.
IMO you are describing a mixed requirement task. For one part you would like serial numbers (those should probably be unique) and the second part describes a have an attribute for sorting that also can be manipulated to move a row in the grid.
While AutoNumber should work I would opt for the CommunityCommons java action getGUID which returns the Global Unique Identifier (GUID, or id) of an object and display it
AutoNumbers can not be manipulated as you are used to with integers and, as stated by Dragos Vrabie, it can be horrible for the performance to keep calculating an attribute that can be used to move an entry up/down in a huge grid, especially when you need to consider object deletion (and the resulting gaps on your sorting). Generally, fun :D
Lukas Tost - CLEVR
Have you tried adding an attribute of type autonumber?
That should work out of the box numbering your objects. However it will store it in the database.
If you want to only display it and not calculate it you could try a calculated attribute but that will impact your performance significantly on 100,000 rows.
Hope this helps
I think Lukas answers most of your questions. I just want to point out something regarding: