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

How to: Filter Data

  • 2 minutes to read

The following example describes how to filter data within a Snap document 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 with this step skipped, you won’t be able to modify the document.
  4. Start modifying the list by calling the SnapEntity.BeginUpdate method.
  5. To apply filtering to the list, add the required string filter expression to the list collection of filter settings, accessible through SnapList.Filters property.
  6. Call the SnapEntity.EndUpdate method to finalize the list modification and update the list fields by calling the FieldCollection.Update method.
' Delete the document's content.
server.LoadDocument("Template.snx")

Dim list As SnapList = server.Document.FindListByName("Data Source 11")
server.Document.ParseField(list.Field)
list.BeginUpdate()
' Apply filtering:
Const filter As String = "[Discontinued] = False"
If Not list.Filters.Contains(filter) Then
    list.Filters.Add(filter)
End If

list.EndUpdate()
list.Field.Update()