-
Notifications
You must be signed in to change notification settings - Fork 40
Search on particular property #15
Comments
hey , |
Thanks for quick reply. |
Okay , you can always search on a particular field and you would get the whole object with it . After that use any property of that object you require. |
Like like, I didn't specify requirement correctly. How to pass single property to search? . In following example i want to search only on name property. |
I'd like to ask this too. I have lengthy models with lots of misc and meta fields, is it possible to filter a list by only one of those fields? Alternatively, is it possible to display only the field that is being matched? Edit: Thanks for making this by the way, great work. |
I would love to accept a PR providing this functionality. |
I am facing same issue ! Can anyone tell me if i want to search based on multiple fields instead of only one. can i do so ? I want to bind multiple search term to multiple fields of dataset. For example, my dataset is like this,
I have different filters like this,
Can anyone tell me how can i achieve this ? Thanks in advance ! |
@apa-narola I am facing a similar issue, currently transform(values: any[], filterMap: any, numberToShow: number) {
if (!values) return values;
if (!filterMap) return values;
return values.filter(value => {
return this._filter(value, filterMap, numberToShow);
});
}
_filter(item: any, filterMap: any, numberToShow: number) {
let cont = 0;
for (let property in filterMap) {
if (!item.hasOwnProperty(property)) {
continue;
}
if (!item[property]) {
continue;
}
if (filterMap[property] === '*') {
cont++;
continue;
}
if (item[property].toString().toLowerCase().includes(filterMap[property].toLowerCase())) {
cont++;
continue;
}
}
return cont === numberToShow;
} This receive a map like this: {
"property": "filterValue"
} And {{ array | filter:filterObj:3 }} This is not the ideal case, but works for me because I need a "and" between all properties, if you need an "or", you can change the |
@aVolpe Thank you very much for your reply to the comment, I shall try the way which you had suggested. |
Might I suggest the following changes to add this functionality. In adding a third optional string variable that defines the object's field to use as a compare. The following change checks for a null or undefined 3rd parameter. If so, just do as normal. If not, then just return the value of
|
Here is the entire typescript source. I created a filter module and used this successfully with and without the field name. Note - If you use a field name, it must be a string or a string variable.
Example use in your template. (Note class and style information has been removed)
|
Did you got a fix for this ? |
Hi,
I want to search on particular property of object instead of search on whole object.
The text was updated successfully, but these errors were encountered: