JS Grid Control Delegates
Applies to: SharePoint Foundation 2010
The JS Grid control supports a variety of delegates. Using these delegates provides you a greater degree of control over the behavior of the JS Grid control.
JS Grid Delegates
The following table lists the JS Grid delegates.
JS Grid Delegate Reference
Delegate |
Description |
---|---|
AddColumnMenuItems(columnKey, fnInsertMenuItem, fnInsertSeparator) |
Used when the column drop-down menu is activated. |
AutoFilter(newState) |
Called when a column header menu is pulled down and an auto filter item selected. |
Called as soon as some data is entered for a new row. |
|
DeleteRecords() |
Called by the grid to request that the page delete currently selected records. |
ExpandColumnMenu (columnKey, position, fnOnMenuCollapsed) |
This delegate is responsible for creating and rendering a column menu. |
Internal only; this delegate is not intended to be used directly in your code. |
|
ExpandDelayLoadedHierarchyNode(recordKey) |
Provides the ability to dynamically modify the hierarchy. |
Internal only; not intended to be called directly from your code. |
|
GetAutoFilterEntries (currentAutoFilterState, initiatingColumnKey, columnKeys, fnSuccess, fnFailure) |
Called when the column menu is dropped down and the grid needs to populate the auto filter entries in the menu. |
Called to get row style information. |
|
GetRecordEditMode(record) |
This delegate is called for each cell of a line when the line is rendered. It is also called if a cell is being selected. |
IndentRecords () |
Called when the grid is requesting the controller to indent the currently selected records. |
Called when the grid is requesting the page to insert a record at the currently selected row. |
|
LaunchFilterDialog(colKey) |
Called when there are too many auto filter entries to display. |
OutdentRecords() |
Called when the grid is requesting the controller to outdent the currently selected records. |
ShowColumnConfigurationDialog() |
Show a custom column configuration dialog. |
Sort(array) |
The page is asking the grid to sort, passing in an array of objects. |
TryInsertEntryRecord(entryRecord, entryRecordPropertyUpdates, fnRecordCommitSucceeded, fnRecordCommitFailed.) |
Called as soon as the user leaves the newly created row. This delegate ends the sequence initiated with the delegate of type CreateEntryRecord. |
WillAddColumnMenuItems(columnKey) |
If the AddColumnItems delegate is going to add items to this column menu, this delegate must return true.
|
JS Grid Delegate Example
This code snippet sets the delegate in the Init method.
Type.registerNamespace("GridManager");
GridManager = function () {
this.Init = function (jsGridControl, initialData, props) {
jsGridControl.SetDelegate(SP.JsGrid.DelegateType.Sort, HandleSort);
var dataSource = new SP.JsGrid.StaticDataSource(initialData);
var jsGridParams = dataSource.InitJsGridParams();
jsGridControl.Init(jsGridParams);
}
// This function will be called when ascending / descending header dropdown is clicked
function HandleSort(newSortedCols) {
var ColumnName = newSortedCols[0].columnName;
var isDescending = newSortedCols[0].isDescending;
// Send these two values to server using callback and bind the grid
}
};
See Also
Reference
Concepts
Other Resources
JS Grid Control Functions