I have a Spring-Boot based Jhipster generated project with Angular. In the project is a Person entity. I want to know how to filter the html CRUD table on inputs on firstname field.
So if I enter in the input "bob" I would get all names containing "bob". Similar to this question. This filter should get the data from backend/server side, and not just what is displayed on the current page.
I am new to Angular so a verbose answer about what files need to be modified would be helpful.
Filtering has been enabled in jhipster. I want the input to trigger a filter server-side.
My table looks like:
I tried have added to my html:
<th>
<form [formGroup]="userForm" (ngSubmit)="onEnter()">
<input type="text" class="form-control" formControlName="firstname">
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
</form>
</th>
In the person.component.ts I have created a method to capture the enter event:
onEnter(): void {
alert(JSON.stringify(this.userForm.value));
this.personService.lastnameContains(this.userForm.value)
}
And looking at person.service.ts which has some examples for update, delete find, I have this method:
lastnameContains(lastname: string): Observable<EntityArrayResponseType> {
return this.http
.get<IPerson[]>(`${this.resourceUrl}?lastname.contains=${lastname}`, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertDateFromServer(res)));
}
The URL the request is sent to should be :
"http://localhost:8080/api/people?lastname.contains=searchstring"
UPDATE
There is a generated query method in the service:
query(req?: any): Observable<EntityArrayResponseType> {
const options = createRequestOption(req);
return this.http
.get<IPerson[]>(this.resourceUrl, { params: options, observe: 'response' })
.pipe(map((res: EntityArrayResponseType) => this.convert1DateArrayFromServer(res)));
}
But it does not seem to have a way to direct the request to the correct URL.
The above picture shows the code is being called. But nothing is sent to the server at all, let alone at /api/person?lastname="somestring"
How does one implement this filtering. Jhispter docs are scant at best.



personis probably defined by*ngForin table body and you're referring to it from the table header outside of the loop on rows. It's not clear whether you want to filter client side or server side. For server side, JHipster has JPA entity filtering, see jhipster.tech/entities-filtering - Gaël Marziou