ASP.NET MVC コントロールヘルプ
DataMap クラス
ファイル
wijmo.grid.js
モジュール
wijmo.grid

列のdataMap プロパティで使用するデータマップを表します。

データマップは、グリッドに自動検索機能を提供します。たとえば、 顧客のIDの代わりに顧客名、RGB値の代わりに色名を 表示できます。

以下のコードは、グリッドを製品のコレクションに連結してから、DataMap をグリッドの'CategoryID'列に割り当てて、グリッドにID自体ではなくカテゴリ名を表示します。

グリッドは、編集にもデータマップを利用します。 wijmo.input モジュールをロードした場合は、データマップされた列の編集時に、マップの値を含むドロップダウンリストが表示されます。

```typescript import { FlexGrid, Column } from '@grapecity/wijmo.grid';

// グリッドを製品に結合します let flex = new FlexGrid({ itemsSource: products });

// IDの代わりにカテゴリ名を表示するようにCategoryID列をマップします let col = flex.getColumn('CategoryID'); col.dataMap = new DataMap(categories, 'CategoryID', 'CategoryName'); ```

一般に、データマップは列全体に適用されます。ただし、別の列の値に基づいて、 セルに使用するオプションを制限することもできます。たとえば、"Country"列と"City"列がある場合は、 現在の国に基づいて都市を制限することがよくあります。

このような「動的」データマップを実装する方法は、次の2つあります。

  1. If the DataMap is just a list of strings, you can change it before the grid enters edit mode. In this case, the cells contain the string being displayed, and changing the map won't affect other cells in the same column. This fiddle demonstrates: show me.
  2. If the DataMap is a real map (stores key values in the cells, shows a corresponding string), then you can apply a filter to restrict the values shown in the drop-down. The DataMap will still contain the same keys and values, so other cells in the same column won't be disturbed by the filter. This fiddle demonstrates: show me.

場合によっては、列挙を表す DataMap を作成することができます。 上記を実現するには、次のコードを使用できます。

```typescript // build a DataMap for a given enum function getDataMap(enumClass) { let pairs = []; for (let key in enumClass) { var val = parseInt(key); if (!isNaN(val)) { pairs.push({ key: val, name: enumClass[val] }); } } return new DataMap(pairs, 'key', 'name'); } ``` DataMap can treat keys in two different ways, this functionality is controlled by the serializeKeys property. By default, key values are converted to strings before processing, that is different values will produce the same key value if their string representations are equal. This is usually the preferred behavior. You maw need to change this mode if your keys are complex objects or arrays of complex objects. See the serializeKeys property documentation for more details.

コンストラクタ

プロパティ

メソッド

イベント

コンストラクタ

constructor

constructor(itemsSource: any, selectedValuePath?: string, displayMemberPath?: string): DataMap

DataMapクラスの新しいインスタンスを初期化します。

パラメーター
戻り値
DataMap

プロパティ

collectionView

マップデータを含むICollectionView オブジェクトを取得します。

ICollectionView

displayMemberPath

項目のビジュアル表現として使用するプロパティ名を取得します。

string

isEditable

ユーザーがDataMap に存在しない値を入力できるかどうかを示す値を取得または設定します。

DataMap を編集可能にするには、selectedValuePathdisplayMemberPath が同じ値に設定されている必要があります。

boolean

selectedValuePath

項目のキー(データ値)として使用するプロパティ名を取得します。

string

serializeKeys

Gets or sets a value indicating whether key values are converted to strings before use.

デフォルト値はtrueです。

This property is set to true by default, which means that for example the keys 123 (number) and ???123??? (string), two Date objects defining the same date/time, and two different arrays of primitive values (like [1,2,3]), are treated as the equal key pairs and mapped to the same value.

If to set this property to false, the keys equality will be determined as in the native Map class, that is using the triple-equality (===) operator. This mode is useful if your keys are objects or arrays of objects. Note that in this case DataMap uses the native browser???s Map implementation. Some old mobile browsers, as well as IE9/10, don???t implement the Map interface. In this case DataMap will use its own array based implementation, which can bring serious performance penalties in case of big data arrays.

boolean

sortByDisplayValues

このDataMapを使用する列のデータを並べ替えるときに、 グリッドコントロールがマップ(表示)または未加工(キー)値を 使用するかどうかを決定する値を取得または設定します。

このプロパティのデフォルト値はtrueです。

boolean

メソッド

getDataItem

getDataItem(key: K): V

指定されたキーに対応する項目を取得します。

パラメーター
  • key: K

    The key of the item to retrieve.

戻り値
V

getDisplayValue

getDisplayValue(key: K): string

指定されたキーに対応する表示値を取得します。

パラメーター
  • key: K

    The key of the item to retrieve.

戻り値
string

getDisplayValues

getDisplayValues(dataItem?: V): string[]

マップのすべての表示値を含む配列を取得します。

パラメーター
  • dataItem: V Optional

    Data item for which to get the display items. This parameter is optional. If not provided, all possible display values should be returned.

戻り値
string[]

getKeyValue

getKeyValue(displayValue: string, html?: boolean): K

指定した表示値に対応するキーを取得します。

パラメーター
  • displayValue: string

    The display value of the item to retrieve.

  • html: boolean Optional

    Whether to convert the lookup values from HTML to plain text.

戻り値
K

getKeyValues

getKeyValues(): K[]

マップのすべてのキーを含む配列を取得します。

戻り値
K[]

onMapChanged

onMapChanged(e?: EventArgs): void

mapChanged イベントを発生させます。

パラメーター
戻り値
void

イベント

mapChanged

マップデータが変更されたときに発生します。

引数
EventArgs