Wijmo 5 [Column type switching]

In flexsheet column type switching from 1. Text to numeric 2. Numeric to text 3. Data Mapping

by Manish Gupta

HTML

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/wijmo.min.css">
<link rel="stylesheet" href="http://cdn.wijmo.com/5.latest/styles/themes/wijmo.theme.office.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.filter.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/controls/wijmo.grid.sheet.min.js"></script>
<script src="http://cdn.wijmo.com/5.latest/interop/angular/wijmo.angular.min.js"></script>
<div ng-app="app">
        <div ng-controller="appCtrl" style="padding:15px;"> 
            <div style="padding:10px;">
                <button class="btn btn-default" ng-click="T2N()">Text to Numeric</button>
                <button class="btn btn-default" ng-click="N2T()">Numeric to Text</button>
                <button class="btn btn-default" ng-click="mapping()">Data Mapping</button>
               
            </div>
            <wj-flex-sheet style="height:500px;" control="flex">
                <wj-sheet items-source="data" ></wj-sheet>

            </wj-flex-sheet>
        </div>
    </div>

JavaScript

var app = angular.module('app', ['wj']);
        app.controller('appCtrl', function ($scope) {
          
          // random data for sheet
          var users = 'user1001_gc,200.1,,11user3001,user,656user'.split(','),
                countries='India,Australia,America,Africa,England'.split(','),
                data=[];
            getData = function (value) {
                for (var i = 1; i <= value; i++) {
                    data.push({ user: users[i % users.length], access:Math.floor(Math.random()*1000),country:countries[i%countries.length] });
                }
                return data;
            };
            $scope.data = new wijmo.collections.CollectionView(getData(15));
            // items source for dropdown menu
            dropdown = 'India,America'.split(',');
            //function for conversion data type from text to numeric
            $scope.T2N = function () {
                $scope.flex.columns[0].dataType = "Number";
                for (var i = 0; i < $scope.flex.rows.length; i++) {
                    var value = '';
                    var data = $scope.flex.getCellData(i, 0, true);
                    for (var j = 0; j < data.length; j++) {
                        if (data[j] >= 0 && data[j] <= 9 || data[j] == '.') {
                            value = value + data[j];
                        }
                    }
                    $scope.flex.setCellData(i, 0, value, false);
                }
            };
            // numeric to text
            $scope.N2T = function () {
                
                $scope.flex.columns[1].dataType = "String";
            };
            //data mapping
            $scope.mapping = function () {   
            //deleting item from column which is not in dropdown
                for (var i = 0; i < $scope.flex.rows.length; i++) {
                    var value = $scope.flex.getCellData(i, 2, true);
                    var isContain = false;
                    for (var j = 0; j <...