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
Related API Members
The following members return SnapList objects:
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.
Example
This procedure generates the Snap template in code by executing the following steps.
- Create a
SnapList
and start its modification by calling the SnapEntity.BeginUpdate method. - Create a SnapList.ListHeader header, add a Table to the header and insert column names.
- Modify the row template. The row template has the SnapDocument interface accessible using the SnapList.RowTemplate property.
- Add a table to the template and insert data-bound text fields into its cells using the ISnapFieldOwner.CreateSnText method.
- Format the table in the list.
- Apply filter to data in the list.
- Sort data in the list.
- Group data in the list
- Finalize the modification by calling the SnapEntity.EndUpdate method.
- Update the result by calling the Field.Update method.
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();
}