JS Grid Events

Applies to: SharePoint Foundation 2010

You can write code that executes on the client when a particular event occurs on the JS Grid control. The client-side rendering of this code provides the user more immediate feedback because a round trip to the server is not required.

The JS Grid control offers the following client-side events.

JS Grid Events

Event

Description

OnBeforeGridDispose

Occurs before the grid is disposed. Occurs only once in the lifetime of the control.

OnCellEditBegin

Occurs when the user has begun editing (keypress, double-click) in an edit control or widget; for example, when the user begins typing in an edit box.

OnCellEditCompleted

Occurs after the user has finished editing a cell with an edit control or widget. Also occurs on a page refresh (an onLoad event).

OnCellErrorStateChanged

Occurs when the cell error state is added or removed.

OnCellFocusChanged

Occurs after the cell focus changes.

OnDoubleClick

Occurs when the user double-clicks a cell.

OnEntryRecordAdded

Occurs when a new entry record appears on the JS Grid control.

OnEntryRecordCommitted

Occurs when the record entry is committed; that is, when an entry record is successfully added to the JS Grid control table cache.

OnEntryRecordPropertyChanged

Occurs when a property of an entry record is changed. This including all user and programmatic edits.

OnGridErrorStateChanged

Occurs when the grid changes from a state of having one or more errors to having no errors, or the reverse.

OnInitialChangesForChangeKeyComplete(changeKey)

Occurs the first time all changes associated with a given change key have been validated; that is, no asynchronous calls are pending.

OnPropertyChanged

Occurs when a property of a record is changed. Includes all user and programmatic edits.

OnRecordChecked

Occurs when one or more records is checked or unchecked by using the record indicator check box.

OnRecordDeleted

Occurs when a record is deleted.

OnRecordInserted

Occurs when a record is inserted.

OnRightClick

Occurs when the user right-clicks the cell.

OnRowErrorStateChanged

Occurs when the error state of a row changes.

OnRowFocusChanged

Occurs when the row focus changes.

OnSingleCellClick

Occurs when the user single clicks a cell.

OnSingleCellKeyDown

Occurs when a single key is pressed.

OnVacateChange

Occurs when the grid is no longer tracking a specified change. For example, if the user makes a change, undoes that change, and then makes a different change, the first change is vacated.

Attaching to Events

This example shows how to attach custom code to the OnCellEditComplete event.

<script type="text/javascript">
    Type.registerNamespace("GridManager");

    GridManager = function () {
        this.Init = function (jsGridControl, initialData, props) {
            control = jsGridControl;
            var dataSource = new SP.JsGrid.StaticDataSource(initialData);
            var jsGridParams = dataSource.InitJsGridParams();

            // This event is triggered after the standard grid error checking.
            jsGridControl.AttachEvent(SP.JsGrid.EventType.OnCellEditCompleted, GotHere);

            jsGridControl.Init(jsGridParams);
        }
    };
    function GotHere(obj) {
        alert('Got Here, ' + obj.fieldKey);

    }
</script>

See Also

Reference

Microsoft.SharePoint.JSGrid

JSGrid