Tips for Implementing the JS Grid Control
Published: May 2010
The controller of the JS Grid control tells the grid how to render content (that is, which panes or columns to display). The controller enables the data source. The controller understands how to handle unrelated rows, allowing edits to occur without having all the data locally.
You can also define styles in the controller. In the following code, RegisterCellStyle defines a style, ‘TextRightAlign’, which can be used to right-align columns.
For a complete example, see How to: Create a Basic JS Grid Control.
The term persistence refers to retaining filter, group, sort, and view selection preferences across user sessions. Persistence is a feature of each controller.
Settings that should not be persisted across sessions include the following:
Autofilter: Persisting autofilter settings can confuse users because they might not understand why their views contain no data. If manually configured, client-side filters are persisted.
Hierarchy: The dataset is created "on the fly," so it is difficult to persist; however, the "show outline level" setting is persisted. This setting causes the view to create the aforementioned dataset.
The selected row or column
In Microsoft Office Project Server 2007, most settings were persisted across sessions. Project Server 2010 still allows a choice of persistence per page. The default should be to retain settings within the user settings unless you have a strong business case for persisting preferences in the session only.
When printing, the controller loads the grid data as read-only. This can be a long-running operation in a paged dataset; it is best to open a new browser window. Printing is left to the browser. If the page does not meet user expectations, the user can close the print window, add or remove columns, zoom, and click Print again.
This example shows how to attach custom code to the OnCellEditComplete event.