Skip to main content
Version: 2.1.4

ListViewService

3p-core v2.1.4


3p-core / ListViewService

Class: ListViewService

A reusable service for loading SharePoint list metadata and items, supporting CAML queries, server-side search, paging, sorting, and filtering.

Designed for use in SPFx solutions with a React ListView component.

Constructors

Constructor

new ListViewService(configuration): ListViewService

Parameters

configuration

IListViewServiceConfig

Returns

ListViewService

Methods

forceRefresh()

forceRefresh(): void

Triggers a refresh event that components using this service can subscribe to.

Returns

void


loadList()

loadList(): Promise<IListInfo>

Loads SharePoint list metadata such as title, ID, and base template.

Returns

Promise<IListInfo>


loadListFields()

loadListFields(): Promise<IFieldInfo[]>

Retrieves all field definitions from the SharePoint list.

Returns

Promise<IFieldInfo[]>


loadListItems()

loadListItems(columns?, pageRef?, rowLimit?, filters?, sortField?, searchText?): Promise<any>

Loads list items from SharePoint with CAML support, column projection, sorting, filtering, and pagination.

Parameters

columns?

string[]

Optional field internal names to include in the view.

pageRef?

string

Optional paging token to retrieve next page of results.

rowLimit?

number

Optional override for row limit per page.

filters?

Key-value map of filter conditions.

sortField?

any

Optional sorting definition { SortField: string, SortDir: 'Asc' | 'Desc' }.

searchText?

string

Optional text query for server-side search.

Returns

Promise<any>


offForceRefresh()

offForceRefresh(callback): void

Unsubscribes a callback from the force refresh event.

Parameters

callback

() => void

The callback to remove.

Returns

void


onForceRefresh()

onForceRefresh(callback): void

Subscribes to the force refresh event.

Parameters

callback

() => void

Function to call when a refresh is triggered.

Returns

void


getFieldInfo()

static getFieldInfo(listFields, internalName): IFieldInfo

Utility function to find a specific field definition by internal name.

Parameters

listFields

any[]

List of IFieldInfo objects.

internalName

string

The internal name of the field.

Returns

IFieldInfo

Properties

PropertyModifierType
camlQuerypublicstring
inPlaceFilterItemspublic(items) => any[]
listNamepublicstring
sppublicSPFI