Skip to main content
A newer version of this page is available. .

How to: Sort Data

The following example demonstrates how to sort Snap document data using the following steps.

  1. Load the document template using the RichEditDocumentServer.LoadDocumentTemplate method.
  2. Call the ISnapFieldOwner.CreateSnList method to create a new Snap list or retrieve one of the existing lists by calling the ISnapFieldOwner.FindListByName method.
  3. Convert the document fields to Snap Fields. To do that, call the ISnapFieldOwner.ParseField method. Note that without performing this step, you won’t be able to modify the document.
  4. Enable modifying the list by calling the SnapEntity.BeginUpdate method.
  5. Create a new sorting parameter represented by the SnapListGroupParam instance. Pass the target field name and the desired sort order to the SnapListGroupParam object’s constructor method.
  6. Add the created object to the corresponding list collection. To do that, access the collection through the SnapList.Sorting property and call the Add method.
  7. Call the SnapEntity.EndUpdate method to finalize the list modification. Then, update the list fields by calling the FieldCollection.Update method.
Dim list As SnapList = server.Document.FindListByName("Data Source 11")
list.Sorting.Add(New SnapListGroupParam("UnitPrice", ColumnSortOrder.Descending))