<h1>
    Dynamic DataMaps
</h1>
<p>
    In some situations, you may want to change the data map used
    with a column depending on the value of another column.
    For example, you may want the drop-down in the 'City' column
    to show only cities in the country that is selected in the
    current row.
</p>
<p>
    This is not as simple as it may seem, because the maps are
    used by all cells, not just by the ones being edited. So
    changing the map values will change the whole grid.
</p>
<p>
    There are two ways to handle this:
</p>
<ul>
    <li>
        <p>
            <b>Customized DataMaps</b>: You can override the DataMap's
            <b>getDisplayValues</b> method to get only values that
            apply to the current context.
        </p>
        <p>
            For example:
        </p>
        <pre>
// create data map
var cityMap = new wijmo.grid.DataMap(getCities(), 'id', 'name');
// override cityMap's getDisplayValues method to get cities that
// correspond to the current item
cityMap.getDisplayValues = function(dataItem) {
  var arr = [],
  cities = getCities(),
  country = theGrid.collectionView.currentItem.country;
  for (var i = 0; i &lt; cities.length; i++) {
    var city = cities[i];
    if (city.country == country) {
      arr.push(city.name);
    }
  }
  return arr;
};</pre>
    </li>
    <li>
        <p>
            <b>String-Only DataMaps</b>: If your data maps contain only
            array strings, then it is not used as a real map. The cells
            actually contain the strings stored in the grid, and in
            this case it is safe to switch data maps before editing
            cells.
        </p>
        <p>
            For example:
        </p>
<pre>
// update cities data map depending on country
beginningEdit: function(s, e) {
  var col = s.columns[e.col];
  if (col.binding == 'city') {
    switch (s.rows[e.row].dataItem.country) {
      case 'US':
        col.dataMap = ['Washington', 'Miami', 'Seattle'];
        break;
      case 'UK':
        col.dataMap = ['London', 'Oxford', 'Bath'];
        break;
      // ... other countries ...
      default:
        col.dataMap = ['Unknown Country!'];
        break;
    }
  }
});</pre>
    </li>
</ul>