How to create a single list view

There are two options for you to begin.

Create the view from scratch

The only thing that your view needs to do to be a legal Site Manager view is to inherit from the base Site Manager view:

public partial class SingleListView : LSOne.ViewCore.ViewBase

You will then have to overwrite key methods from the base class to get your functionality ready. To get an idea of which functions to overload, see the functions overview below.

Copy SingleListView from the Hello World plugin

You can copy almost any view from the Site Manager and customize it based on your needs. To make this process simpler we have created view templates with minimal functionality included. You can find a template view for a single list view in the Hello World plugin from the Site Manager part of the development package. The view is called SingleListView and you can copy it into your plugin. The view contains a shell for the basic functionality of a single list view.

Functions overview

Base functions

This is a list of functions that are most commonly overwritten to add logic to your view:

Base functions

Description

void LoadData(
bool isRevert)

Here we load data into our list view. This involves fetching the list of data objects and populating the list view with it. The isRevert variable is false unless the user pressed the Revert button above the Context bar. That function is supposed to revert to the last saved state of the view (basically reverting all changes that have not yet been saved).

RecordIdentifier ID

Returns the ID of the view and is used to determine if the view is already visible and does not need to be reloaded. Usually you return the ID of the object that you are working with, but since you have a list view you return RecordIdentifier.Empty

string LogicalContextName

Returns the string that should appear directly above the Context bar.

void GetAuditDescriptors(

List<AuditDescriptor> contexts)

Connects the view with an audit view. See chapter Auditing for more details.

void OnDataChanged(..)

This is the opposite function of NotifyDataChanged(..) function that we covered in chapter How to create a simple view . This is the listener function and when another view or dialog wants to notify all open views about changes then this function is called. This function is mainly used to reload the list of objects to make sure we are showing the latest version of the data.

List view operations

This is a list of common functions that are connected to the list view:

List view functions

Description

void

listView_SelectionChanged(..)

This function is called when the user changes the selected index of the list view. Here you need to check if the user clicked on a data object row or if he clicked outside the data rows. If he did not click on a data object row you need to disable the edit and delete buttons.

void listView_RowDoubleClick(..)

This function is called when the user double clicks on a row in the list view. Here you need to make sure that the user clicked on a data object row. If he did you should open the edit view or dialog.

void listView_HeaderClicked(..)  

This function is called when the user clicks on a column in the list view. This is usually used to order the results of the list view depending on the clicked column. Note that to keep the examples simple this function is not used in the Hello World SingleListView.

void ContextMenuStrip_Opening(..)

This function is called when the user right-clicks on the list view. This function is usually linked to the list view in the constructor. In this function you can add different operations that appear to the user in a drop-down list.

Buttons operations

This is a list of the three functions behind the context buttons that are usually located below the list view. Note that it is customary in the Site Manager to disable buttons that you cannot press. This means that the user should not be able to open an add dialog if they do not have permission to add the object.

Context buttons functions

Description

void btns_AddButtonClicked(..)

This operation is called when the user presses the green plus button below the list view. This usually triggers a dialog showing either all the fields that can be edited or just the mandatory fields. If only mandatory fields are shown then the user is redirected to a view for the data object where they can edit the optional parameters of the object.

void btns_EditButtonClicked(..)

This operation is called when the user presses the yellow pencil button below the list view. This should either trigger a dialog where the data object can be edited (if it has a limited amount of information) or another view where the data object can be edited.

void btns_RemoveButtonClicked(..)  

This operation is called when the user presses the red minus button below the list view. This usually triggers a question if the user really wants to delete the selected object (this is not a requirement). If the user presses Yes then the data object is deleted through the data layer.

Sample code walkthrough

 

Next you learn about the double list view: How to create a double list view