Wijmo 5 - FlexGrid Drop-downs

by Ross Dederer

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="http://prerelease.componentone.com/wijmo5/latest/controls/wijmo.min.js"></script>
<link rel="stylesheet" href="http://prerelease.componentone.com/wijmo5/latest/styles/wijmo.min.css">
<script src="http://prerelease.componentone.com/wijmo5/latest/controls/wijmo.grid.min.js"></script>
<script src="http://prerelease.componentone.com/wijmo5/latest/controls/wijmo.input.min.js"></script>
<script src="http://prerelease.componentone.com/wijmo5/latest/controls/wijmo.chart.min.js"></script>
<script src="http://prerelease.componentone.com/wijmo5/latest/controls/wijmo.grid.filter.min.js"></script>
<script src="http://prerelease.componentone.com/wijmo5/latest/interop/angular/wijmo.angular.min.js"></script>
<!-- mark this as an Angular application and give it a controller -->
<div ng-app="app" ng-controller="appCtrl">
    
<h1>FlexGrid with DataMapped Filtering</h1>

    <p>This is a <b>FlexGrid</b> control.   The first Column is displaying the data-mapping for the state code. 
        
        The States Name and Code is found in the state array while its respective properties for each state code is mapped via stateMap.
        <p>
        $scope.stateMap = new wijmo.grid.DataMap(state, "code", "name");</p>
        
        This allows you to map your flexgrid to the properties data array but displaying its respective mappings from state array.
    <wj-flex-grid items-source="data" selection-mode="Row">
        <wj-flex-grid-filter></wj-flex-grid-filter>
        <wj-flex-grid-column header="States" binding="code" data-map="stateMap"></wj-flex-grid-column>
        <wj-flex-grid-column header="City" binding="city"></wj-flex-grid-column>
           <wj-flex-grid-column header="Population" binding="pop"></wj-flex-grid-column>
    </wj-flex-grid>
</div>

JavaScript

// define app, include Wijmo 5 directives
var app = angular.module('app', ['wj']);

// controller
app.controller('appCtrl', function ($scope) {

    // create some random data
    var state = [{
        name: 'Washington',
        code: 'WA'
    }, {
        name: 'California',
        code: 'CA'
    }, {
        name: 'Oregon',
        code: 'OR'
    }];
    var properties = [{
        code: 'WA',
        isSelected: false,
        isState: false,
        city: 'Seattle',
        pop: 652
    }, {
        code: 'OR',
        isSelected: false,
        isState: false,
        city: 'Portland',
        pop: 609
    }, {
        code: 'CA',
        isSelected: false,
        isState: false,
        city: 'Los Angeles',
        pop: 3884
    }];
      
    // expose data as a CollectionView to get events
    $scope.data = new wijmo.collections.CollectionView(properties);
    $scope.stateMap = new wijmo.grid.DataMap(state, "code", "name");
 
});