问题
I want ng-grid not to search based on specific columns, but I do want those columns to still be sortable.
Is there a way to accomplish this?
回答1:
Sorry I'm late, meetings all day:-\ Got this running with a modfied version of my answer example from here.
This one is based on the official server sided pagination example from here.
I changed the code in $scope.getPagedDataAsync
to include this filtering function:
if (searchText) {
var ft = searchText.toLowerCase();
data = $scope.longData.filter(function(item) {
var si=JSON.stringify(item.allowance).toLowerCase()+JSON.stringify(item.paid).toLowerCase();
if (si.indexOf(ft)!=-1){
return item;
};
});
This will generate a string from the column data fields allowance
and paid
, ingores the name
column, and searches the generated string for any occurrence of the search text. Add more colums to your liking.
If searchtext
is found anywhere in the string the item is returned to ng-grid.
This is case insensitive, hence the toLowerCase()
part.
Find a working Plunker here.
来源:https://stackoverflow.com/questions/25529493/disable-filtering-on-a-column-in-ng-grid