Loading Data
Loading data into a CollectionView is straightforward.
Loading on the Client
If you already have the data in an array, you can use that array as a constructor parameter, or set the sourceCollection property to that array:
- Austria sales: 448.95 (id: 5)
- Germany sales: 3,638.67 (id: 1)
- Italy sales: 6,512.70 (id: 4)
- Japan sales: 8,205.44 (id: 3)
- UK sales: 9,009.89 (id: 2)
- US sales: 9,186.87 (id: 0)
Loading from the Server
If the data is on a server, you can retrieve it by using the httpRequest method. When you get a response from the server, set the sourceCollection array to the response value or append new data to the sourceCollection array:
Construct in Server
The server side CollectionViewService control constructs a client side CollectionView instance. You can get the instance by c1.getService method.
- US sales: 81,732.54 (id: 0)
- Germany sales: 20,603.32 (id: 1)
- UK sales: 44,217.79 (id: 2)
- Japan sales: 29,190.63 (id: 3)
- Italy sales: 46,951.19 (id: 4)
- Greece sales: 86,237.02 (id: 5)
If your data service API supports commands such as filtering, sorting, and paging, you can add parameters to your httpRequest calls to support these features. You can even encapsulate the server API into a custom class that extends CollectionView.