<commit_before><!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!--[if lt IE 9]>
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <![endif]-->
    <script src="js/angular.min.js"></script>
    <script src="../ng-table.js"></script>
    <link rel="stylesheet" href="../ng-table.css">
</head>
<body ng-app="main">

<h1>Dynamic columns</h1>

<div ng-controller="DemoCtrl">

    Columns:
    <label class="checkbox" ng-repeat="column in columns">
        <input type="checkbox" ng-model="column.visible" /> {{column.title}}
    </label>

    <table ng-table="tableParams" show-filter="true" class="table">
        <tr>
            <th ng-repeat="column in columns" ng-show="column.visible"
                class="text-center sortable" ng-class="{
                    'sort-asc': tableParams.isSortBy(column.field, 'asc'),
                    'sort-desc': tableParams.isSortBy(column.field, 'desc')
                  }"
                ng-click="tableParams.sorting(column.field, tableParams.isSortBy(column.field, 'asc') ? 'desc' : 'asc')">
                {{column.title}}
            </th>
        </tr>
        <tr ng-repeat="user in $data">
            <td ng-repeat="column in columns" ng-show="column.visible" sortable="column.field">
                {{user[column.field]}}
            </td>
        </tr>
    </table>

    <script>
        var app = angular.module('main', ['ngTable']).
                controller('DemoCtrl', function($scope, $filter, ngTableParams) {
                    var data = [{name: "Moroni", age: 50},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34},
                        {name: "Tiancum", age: 43},
                        {name: "Jacob", age: 27},
                        {name: "Nephi", age: 29},
                        {name: "Enos", age: 34}];
                    $scope.columns = [
                        { title: 'Name', field: 'name', visible: true, filter: { 'name': 'text' } },
                        { title: 'Age', field: 'age', visible: true }
                    ];
                    $scope.tableParams = new ngTableParams({
                        page: 1,            // show first page
                        count: 10,          // count per page
                        filter: {
                            name: 'M'       // initial filter
                        }
                    }, {
                        total: data.length, // length of data
                        getData: function($defer, params) {
                            // use build-in angular filter
                            var orderedData = params.sorting() ?
                                    $filter('orderBy')(data, params.orderBy()) :
                                    data;

                            $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                        }
                    });
                })
    </script>

</div><commit_msg>add example of dynamic grouping<commit_after><!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!--[if lt IE 9]>
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <![endif]-->
    <script src="js/angular.min.js"></script>
    <script src="../ng-table.js"></script>
    <link rel="stylesheet" href="../ng-table.css">
</head>
<body ng-app="main">

<h1>Dynamic grouping</h1>

<div ng-controller="DemoCtrl">

    Group by:
    <select ng-model="groupby">
        <option value="name">Name</option>
        <option value="age">Age</option>
        <option value="role">Role</option>
        <option value="date">Etc</option>
    </select>
    <br>
    Grouped by: <b>{{groupby}}</b>

    <table ng-table="tableParams" class="table">
        <tbody ng-repeat="group in $groups">
        <tr class="ng-table-group">
            <td colspan="{{$columns.length}}">
                <a href="" ng-click="group.$hideRows = !group.$hideRows">
                    <span class="glyphicon" ng-class="{ 'glyphicon-chevron-right': group.$hideRows, 'glyphicon-chevron-down': !group.$hideRows }"></span>
                    <strong>{{ group.value }}</strong>
                </a>
            </td>
        </tr>
        <tr ng-hide="group.$hideRows" ng-repeat="user in group.data">
            <td sortable="name" data-title="'Name'">
                {{user.name}}
            </td>
            <td sortable="age" data-title="'Age'">
                {{user.age}}
            </td>
            <td sortable="name" data-title="'Role'">
                {{user.role}}
            </td>
            <td sortable="name" data-title="'Etc'">
                {{user.date}}
            </td>
        </tr>
        </tbody>
    </table>

    <script>
        var app = angular.module('main', ['ngTable']).
                controller('DemoCtrl', function($scope, $filter, ngTableParams) {
                    $scope.rows = [{name: "Moroni", age: 50, role: 'Administrator', date: '00/00/01'},
                        {name: "Tiancum", age: 43, role: 'Administrator', date: '00/00/01'},
                        {name: "Jacob", age: 27, role: 'Administrator', date: '00/00/01'},
                        {name: "Nephi", age: 29, role: 'Moderator', date: '00/00/01'},
                        {name: "Enos", age: 34, role: 'User', date: '00/00/01'},
                        {name: "Tiancum", age: 43, role: 'User', date: '00/00/01'},
                        {name: "Jacob", age: 27, role: 'User', date: '00/00/01'},
                        {name: "Nephi", age: 29, role: 'Moderator', date: '00/00/01'},
                        {name: "Enos", age: 34, role: 'User', date: '00/00/01'},
                        {name: "Tiancum", age: 43, role: 'Moderator', date: '00/00/01'},
                        {name: "Jacob", age: 27, role: 'User', date: '00/00/01'},
                        {name: "Nephi", age: 29, role: 'User', date: '00/00/01'},
                        {name: "Enos", age: 34, role: 'Moderator', date: '00/00/01'},
                        {name: "Tiancum", age: 43, role: 'User', date: '00/00/01'},
                        {name: "Jacob", age: 27, role: 'User', date: '00/00/01'},
                        {name: "Nephi", age: 29, role: 'User', date: '00/00/01'},
                        {name: "Enos", age: 34, role: 'User', date: '00/00/01'},
                        {name: "Micah", age: 29, role: 'Moderator', date: '00/00/01'},
                        {name: "Viviane", age: 34, role: 'Moderator', date: '00/00/01'},
                        {name: "Marconi", age: 43, role: 'User', date: '00/00/01'},
                        {name: "Leonan", age: 27, role: 'Administrator', date: '00/00/02'},
                        {name: "Arnaldo", age: 29, role: 'User', date: '00/00/02'},
                        {name: "Zuleide", age: 34, role: 'Moderator', date: '00/00/02'}];

                    $scope.groupby = 'role'; //Default order IF null get table without groups(not possible ?)

                    //dinamic grouping
                    $scope.tableParams = new ngTableParams({
                        page: 1,            // show first page
                        count: 100          // count per page
                    }, {
                        groupBy: $scope.groupby,
                        total: function () { return $scope.rows.length; }, // length of data
                        getData: function($defer, params) {
                            var orderedData = params.sorting() ?
                                    $filter('orderBy')($scope.rows, $scope.tableParams.orderBy()) :   $scope.rows;

                            $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                        }
                    });

                    $scope.$watch('groupby', function(value){
                        $scope.tableParams.settings().groupBy = value;
                        console.log('Scope Value', $scope.groupby);
                        console.log('Watch value', this.last);
                        console.log('new table',$scope.tableParams);
                        $scope.tableParams.reload();
                    });
                })
    </script>

</div>
{'fraction_non_alphanumeric': 0.18452935694315004, 'fraction_numerical': 0.02744123433778606, 'mean_word_length': 1.507920020773825, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1637617', 'n_tokens_mistral': 3167, 'n_tokens_neox': 2797, 'n_words': 659}