angular ui-MALE/FEMALE 的网格过滤器问题
angular ui-grid filter issues with MALE/FEMALE
我正在使用 angular ui-网格,底线是我有一个 'gender' 列,其中包含 "MALE" 和 "FEMALE"。当我单击 "MALE" 下拉菜单时,所有男性和女性都会出现(显然是因为 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' }
]
}
},
您可以提供自定义过滤功能。更改您的 column def
以具有自定义过滤器功能。
{
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
是当前行的值。如果此函数 returns true
,则显示一行。
试试这个
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' }]
}
我正在使用 angular ui-网格,底线是我有一个 'gender' 列,其中包含 "MALE" 和 "FEMALE"。当我单击 "MALE" 下拉菜单时,所有男性和女性都会出现(显然是因为 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' }
]
}
},
您可以提供自定义过滤功能。更改您的 column def
以具有自定义过滤器功能。
{
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
是当前行的值。如果此函数 returns true
,则显示一行。
试试这个
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' }]
}