ViewFields

Configure SharePoint view fields in a list view.


Access

Access the ViewFields API using the viewFields property of View.

Examples

up(engineer) {
// Add field to view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.add('My New Field');
}

Methods

add(field)

Add field to the target View.

Parameters

field
The name of the field to add to the view; this field must already be available in the list (String, required)

Examples

up(engineer) {
// Add field to view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.add('My New Field');
}

remove(field)

Remove field from the target View.

Parameters

field
The name of the field to be removed from the view (String, required)

Examples

down(engineer) {
// Remove field from view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.remove('My New Field');
}

removeAll()

Remove all fields from the target View.

Examples

down(engineer) {
// Remove all fields from view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.removeAll();
}

move(field, index)

Move a view field to a new index in the target View.

Parameters

field
The name of the field to be moved in the view (String, required)
index
The new zero-based index for the view field (Number, required)

Examples

up(engineer) {
// Add field to view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.add('My New Field');

// Move new field to first column in view
engineer.web.lists.getByTitle('My List').views.getByTitle('All Items').viewFields.move('My New Field', 0);
}