Skip to main content
All docs
V21.2

SnapList Interface

Provides functionality to manipulate lists in Snap documents.

Namespace: DevExpress.Snap.Core.API

Assembly: DevExpress.Snap.v21.2.Core.dll

NuGet Package: DevExpress.Snap.Core

Declaration

public interface SnapList :
    SnapEntity,
    IDisposable

Remarks

For more information, refer to Snap List and Document Template.

Note

Snap list modifications at runtime must be wrapped in the SnapEntity.BeginUpdate and SnapEntity.EndUpdate method calls.

An empty paragraph before the SnList is a part of the field result. When the SnapList is updated, the paragraph content can be lost. This paragraph is marked by a cross to prevent it from editing. Click Show/Hide Paragraph Mark on the Home tab or press Shift+Ctrl+8 to show the cross symbol.

SnapList

Example

This procedure generates the Snap template in code by executing the following steps.

  1. Create a SnapList and start its modification by calling the SnapEntity.BeginUpdate method.
  2. Create a SnapList.ListHeader header, add a Table to the header and insert column names.
  3. Modify the row template. The row template has the SnapDocument interface accessible using the SnapList.RowTemplate property.
  4. Add a table to the template and insert data-bound text fields into its cells using the ISnapFieldOwner.CreateSnText method.
  5. Format the table in the list.
  6. Apply filter to data in the list.
  7. Sort data in the list.
  8. Group data in the list
  9. Finalize the modification by calling the SnapEntity.EndUpdate method.
  10. Update the result by calling the Field.Update method.

View Example

private void GenerateLayout(SnapDocument doc) {
    // Add a Snap list to the document.
    SnapList list = doc.CreateSnList(doc.Range.End, @"List");
    list.BeginUpdate();
    list.EditorRowLimit = 100;

    // Add a header to the Snap list.                                                                   
    SnapDocument listHeader = list.ListHeader;
    Table listHeaderTable = listHeader.Tables.Create(listHeader.Range.End, 1, 3);
    TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells;
    listHeader.InsertText(listHeaderCells[0].ContentRange.End, "Product Name");
    listHeader.InsertText(listHeaderCells[1].ContentRange.End, "Units in Stock");
    listHeader.InsertText(listHeaderCells[2].ContentRange.End, "Unit Price");

    // Customize the row template.
    SnapDocument listRow = list.RowTemplate;
    Table listRowTable = listRow.Tables.Create(listRow.Range.End, 1, 3);
    TableCellCollection listRowCells = listRowTable.FirstRow.Cells;
    listRow.CreateSnText(listRowCells[0].ContentRange.End, @"ProductName");
    listRow.CreateSnText(listRowCells[1].ContentRange.End, @"UnitsInStock");
    listRow.CreateSnText(listRowCells[2].ContentRange.End, @"UnitPrice \$ $0.00");

    // Apply formatting, filtering and sorting to the Snap list. 
    FormatList(list);
    FilterList(list);
    SortList(list);
    GroupList(list);

    list.EndUpdate();
    list.Field.Update();
}
See Also