MALE / FEMALE的角度ui-grid过滤器问题

时间:2017-02-10 17:42:46

标签: angular-ui-grid

我使用角度ui-grid,底线是我有一个“性别”列,其中包含“MALE”和“FEMALE”。当我单击“MALE”下拉列表时,所有MALE和FEMALE都显示出来(显然因为m-a-l-e在f-e-m-a-l-e中)。如何让过滤器区分两者?

      {
        field: 'sex'
        , displayName: 'SEX'
        , width: '120'
        , editableCellTemplate: '<div><form name="inputForm"><input type="INPUT_TYPE" ng-class="\'colt\' + col.uid" ui-grid-editor ng-model="MODEL_COL_FIELD" style="border-bottom-color: #74B3CE; border-bottom-width: 2px;"></form></div>'
        , filter: {
            type: uiGridConstants.filter.SELECT,
            selectOptions: [
                { value: 'male', label: 'male' },
                { value: 'female', label: 'female' }
            ]
          }
      },

2 个答案:

答案 0 :(得分:1)

您可以提供自定义功能进行过滤。将{ filter: { type: uiGridConstants.filter.SELECT, selectOptions: [ { value: 'male', label: 'male' }, { value: 'female', label: 'female' } ], condition: customFilterSelected } }, 更改为具有自定义过滤功能。

customFilterSelected

然后定义function customFilterSelected(function filterSelected(term, value, row, column) { return term === value; }

term

每次对每行进行过滤器更改时都会运行此函数。参数value是filter的值,true是当前行的值。如果此函数返回{{1}},则显示一行。

答案 1 :(得分:0)

尝试一下

name: 'gender', displayName: 'Gender', enableHiding: false, resizeable: true,
filter: {
     type: uiGridConstants.filter.SELECT,
     condition: uiGridConstants.filter.EXACT,
     selectOptions: [{ value: 'Male', label: 'Male' }, { value: 'Female', label: 'Female' }, { value: 'Other', label: 'Other' }]
}