Angular 1.5 SharePoint,仅显示选定的部门

时间:2016-10-12 12:05:08

标签: angularjs sharepoint sql-order-by

我已经从SharePoint列表中创建了一个小型Angular员工电话簿应用程序。该应用程序基于其他教程:

http://ramdotnetdeveloper.blogspot.no/2016/05/sharepoint-2013-filtering-and-sorting.html

虽然scope.sortExpression执行其作业排序,让我们说标题,部门,经理等....我想,因为有子部门能够将这些作为选项添加到下拉列表中,并且只显示这些结果。

因此,如果我选择部门DEP I 1,它只会显示属于该部门的人员,DEP I 2等等是否可以通过某种过滤?

var app = angular.module('ansattApp', ['angularUtils.directives.dirPagination']);           

app.controller('ansattController', function ($scope, $http) { 

    $http({ 
        method: 'GET', 
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Telefonkatalog')/items?$top=1000", 
        headers: { "Accept": "application/json;odata=verbose" } 
    }).success(function (data, status, headers, config) { 
        $scope.ansatte = data.d.results;
        $scope.mySortFunction = function(ansatt)  { 
          //Sorting Item  
          if (isNaN(ansatt[$scope.sortExpression]))  
            return ansatt[$scope.sortExpression];  
          return parseInt(ansatt[$scope.sortExpression]);  
        }           
    }).error(function (data, status, headers, config) {}); 
});  

HTML

<div data-ng-app="ansattApp" class="row"> 

   <div data-ng-controller="ansattController" class="span10">

 <div class="form-group">
  <div>  
        <h5>Sorter etter: </h5> 
        <select ng-model="sortExpression" class="form-control">  
            <option value="Title">Tittel</option>  
            <option value="Seksjon">Seksjon</option>
                        </select>  
    </div>  


   <input type=text" data-ng-model="search" placeholder="Søk etter ansatte,seksjon m.m." class="form-control"/>

<h1>{{search }}</h1>

    <table class="table table-striped table-hover">

       <tbody> 

        <tr> 

            <th>Etternavn</th> 

            <th>Fornavn</th> 

            <th>Tittel</th>

            <th>Enhet</th>

            <th>Kontor</th>

                           <th>Arbeid</th>

                           <th>Mobil</th>



        </tr> 

        <tr dir-paginate="ansatt in ansatte | filter:search  | orderBy:mySortFunction   | itemsPerPage:25"> 

            <td>{{ansatt.Etternavn}}</td> 

            <td>{{ansatt.Fornavn}}</td> 

            <td>{{ansatt.Title}}</td>

            <td>{{ansatt.Seksjon}}</td>

            <td>{{ansatt.Kontornummer}}</td>

            <td>{{ansatt.Arbeid}}</td>

            <td>{{ansatt.Mobil}}</td>

            </tr>

       </tbody> 

    </table>

            <dir-pagination-controls

               max-size="500"

               direction-links="true"

               boundary-links="true"

               on-page-change="data.getData(newPageNumber)" >

            </dir-pagination-controls>

</div> 

0 个答案:

没有答案