Version

Editor Providers

There may be times in which you might want to use different editors for fields in WebHierarchicalDataGrid™. You can do so through the use of editor providers.

On an editing-enabled WebHierarchicalDataGrid control, the most appropriate editor provider will be used on each column depending on the column’s data type. For example, numeric and DateTime data type columns will automatically use the NumericEditorProvider and the DateTimeEditorProvider respectively. However, if you wish to override this default functionality, you can always specify your own editor provider(s). This allows you to provide different editors you deem more appropriate for each column. The available editor providers are:

Some of the editor providers used by default depending on the data type of WebHierarchicalDataGrid’s columns are listed below. The following table lists the data types and their associated editors.

Type Editor

Byte

WebNumericEditorProvider

Char

WebNumericEditorProvider

DateTime

DateTimeEditorProvider

Double

NumericEditorProvider

Int16

NumericEditorProvider

Int32

NumericEditorProvider

Int64

NumericEditorProvider

Single

NumericEditorProvider

String

TextBoxProvider

To use editor providers, add them to the EditorProviders collection. Once added, you can access an editor provider with its Id and assign it to a particular column.

The following walkthrough shows how to use EditorProviders with your WebHierarchicalDataGrid control.

Follow these Steps

  1. Bind WebHierarchicalDataGrid to a WebHierarchicalDataSource™ component retrieving data from the Orders and Order Details tables. For more information on doing this, see the Using WebHierarchicalDataSource topic.

  2. In the Microsoft® Visual Studio™ property window, locate the EditorProviders property and click the ellipsis (…​) button to launch the Editor Providers Designer.

  3. Click the Plus (+) button to drop-down a list of possible editors. Select two Editors, one for the parent band and one for the child band to make it available later when you are setting up columns. For our purposes, select the DatePickerProvider and the SliderProvider.

WebHierarchicalDataGrid Using Editor Providers 01.png
  1. Leave the ID for the editors as WebHierarchicalDataGrid1_DatePickerProvider1 and WebHierarchicalDataGrid1_SliderProvider1 in the property grid on the right. You will need this ID later when setting the editors for columns.

  2. You can set any additional properties for the editor controls by expanding the EditorControl property. For this topic, expand the EditorControl property of the SliderProvider. Set values for the following properties:

    • MaxValue – 150

    • MinValue – 0

    • ValueType – Int

WebHierarchicalDataGrid Using Editor Providers 02.png
  1. Click Apply then OK to close the designer

  2. Locate the Bands property and click the ellipsis (…​) button to launch the Edit WebHierarchicalDataGrid Bands Dialog.

  3. In this window you can set properties for the parent and child bands. Locate the Behaviors property from the property grid on the right for the parent band. Click the ellipsis (…​) button to launch the Edit Grid Behaviors dialog.

WebHierarchicalDataGrid Using Editor Providers 03.png
  1. Check the CellEditing behavior in the list on the left to enable editing.

  2. Locate the ColumnSettings property in the property grid on the right and click the ellipsis (…​) button to launch the Column Settings Editor Dialog.

  3. Configure parent band of WebHierarchicalDataGrid to use the DatePickerProvider for editing of the RequiredDate column.

    1. Add a column setting by clicking add item.

    2. Set the ColumnKey as RequiredDate.

    3. For the EditorID property, click the dropdown list and select

WebHierarchicalDataGrid 1_DatePickerProvider1. Only editors that are added to the EditorProviders collection are available here. .. Leave ReadOnly as False. .. Click OK in the Column Setting and Edit Grid Behaviors dialog windows.

Note
Note:

You can also select the Add/Modify Columns option in the drop-down list to go to the Edit Grid Columns dialog.

WebHierarchicalDataGrid Using Editor Providers 04.png
  1. Follow steps 8 to 10, but this time to configure the child band.

  2. Configure child band of WebHierarchicalDataGrid to use the SliderProvider for editing of the Quantity column.

    1. Add a column setting by clicking add item.

    2. Set the ColumnKey as Quantity.

    3. For the EditorID property, click the dropdown list and select WebHierarchicalDataGrid1_SliderProviderProvider1. Only editors that are added to the EditorProviders collection are available here.

    4. Leave the ReadOnly property as False.

    5. Click OK in the Column Setting and Edit Grid Behaviors dialog windows.

WebHierarchicalDataGrid Using Editor Providers 05.png
  1. Click OK to close the Edit WebHierarchicalDataGrid Bands dialog.

  2. Run your application. When you enter edit mode in a cell of the RequiredDate column, the DatePickerProvider displays. Similarly when you enter edit mode in a cell of the Quantity column within the child band, the SliderProvider displays.

WebHierarchicalDataGrid - Parent Band showing DatePickerProvider in RequiredDate column
WebHierarchicalDataGrid Using Editor Providers 06.png
WebHierarchicalDataGrid - Child Band showing SliderProvider in Quantity column
WebHierarchicalDataGrid Using Editor Providers 07.png