2017-02-25 32 views
0

我在UI-GRID中的排序功能有问题。 目前我收到这样我的数据:AngularJS在单元格中的网格排序模板

{ 
AccountID : 555, 
Teacher: Somename, 
SchoolName: 1 
}, 

{ 
AccountID : 555, 
Teacher: Somename, 
SchoolName: 2 
} 

我使用的是dictonary我Schoolnames和我想象他们:

if (memberData.type == "dictionary") { 
columnDef.cellTemplate = 
'<div class="ui-grid-cell-contents"> 
{{ grid.appScope.GetDictionaryItemValue("' + memberData.dictionaryID + '", COL_FIELD) }} 
</div>'; 

问题这里的排序功能是将学校 排序,而不是从学院名称收到,但根据他们的ID。

什么将是解决这一问题的最佳解决方案?

我试过使用cellFilter而不是cellTemplate,但它也是通过ID对它们进行排序的。

回答

0

只是cellFilter再次尝试,实际上它的工作原理是这样的:

columnDef.cellFilter = 'dictionaryFilter:"' + this + '"'; 

columnDef.sortCellFiltered = true; 

目前是手工我的过滤代码:

.filter('dictionaryFilter', function() { 
     return function(input) { 


      if (input == 2) { 
       input = 'High School'; 
      } 
      if (input == 3) { 
       input = 'Other School'; 
      } 
      if (input == 16) { 
       input = 'Another School'; 
      } 

      return input; 

     } 

有没有从这个访问父控制器范围的方式过滤?我不想在过滤器中强调dictonary。