2017-08-24 115 views
0

我使用自定義篩選,因爲它是在這個答案https://stackoverflow.com/a/29608444/3883369自定義自定義篩選排序在TrNgGrid

顯示這是我的代碼

<th field-name="FileName" display-name="{{ 'FileName' | translate }}"> 
    <div class="tr-ng-column-filter tableHeaderOverTitleElement"> 
     <input class="form-control" 
       ng-model="filtersWrapper.mFileName" value="" 
       placeholder="{{'refNoAndFilename'|translate}}" 
       ng-enter="makeFilteredCallWithDefaultData()"> 
    </div> 
    <div class="tr-ng-title">{{ 'FileName' | translate }}</div> 
</th> 

添加自定義篩選的默認排序消失後不幸。你可以幫助排序嗎?

lack of sorting

我使用TrNgGrid版本3.1.7

回答

0

創建用戶defind搜索輸入

div class="container" style="padding-left: 0px;"> 
    <form> 
    <div class="form-group" style="margin-bottom: 0px;"> 
     <div class="input-group" style=" margin-left: 15px;"> 
     <div class="input-group-addon" style=" padding-left: 15px;"><span> Filter </span></div> 
     <input type="text" class="form-control" placeholder="Type here..." ng-model="searchFish" style="width: 92%;"> 
     </div>  
    </div> 
    </form> 
</div> 

短記錄

<table class="table table-bordered table-striped" id="myTable" style=" width: 99%;max-width: 93%; text-align: center;" > 
    <thead> 
    <tr> 
     <th style="border: 0px solid #ddd;" class="textbgcolor textcenter"> user id # <img src="img/up.svg" style="width: 13px;" ng-click="orderProperty = 'user_id'"/> </th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr ng-repeat="t in current_table | orderBy:orderProperty | orderBy:use_id | filter:searchFish "> 
    <td style=" border: 0px solid #ddd;"> {{t.use_id}} </td> 
    </tr> 
    </tbody> 
</table> 

是funcation直接使用

//========================================================== asssending and discending oreder funcation 

$scope.setOrderProperty = function(propertyName) { 
    if ($scope.orderProperty === propertyName) { 
     $scope.orderProperty = '-' + propertyName; 
    } else if ($scope.orderProperty === '-' + propertyName) { 
     $scope.orderProperty = propertyName; 
    } else { 
     $scope.orderProperty = propertyName; 
    } 
} 

// -===================================================== 

    $scope.sortType  = 'x.user_id' // set the default sort type 
    $scope.sortReverse = false; // set the default sort order 
    $scope.searchFish = '';  // set the default search/filter term