fatCop
fatCop

Reputation: 2576

How to edit entity and add pagination in Jhipster generated project

Already several entities are created. Initially infinite scroll option was selected while creating entities. Now I want to implement pagination instead of infinite scroll. Should I overwrite the entities?

Upvotes: 6

Views: 7672

Answers (2)

Vaibhav
Vaibhav

Reputation: 146

There are following 2 cases,

You can identify your case by observing "pagination" option from EntityName.json file from ./ProjectName/.jhipster directory,

Case 1: "pagination": "infinite-scroll" i.e. existing pagination is available

In this case, you can regenerate entities with a less impact. Refer @geraldhumphries answer. How to edit entity and add pagination in Jhipster generated project

Case 2: "pagination": "no" i.e. existing pagination is not available

To add pagination to existing entity change "pagination" option from "pagination": "no" to "pagination": true and update entities by using, yo jhipster:entity EntityName or by importing jhipster import-jdl jdl.jh[In case of JDL]

but In this case, the impact will be on both the server and client side.
On the server side mainly EntityNameResource.java and EntityNameService.java will change.
On the client side EntityName.component.html, multiple supporting.ts files will change.

Upvotes: 2

geraldhumphries
geraldhumphries

Reputation: 1493

In JHipster, the difference between pagination and infinite scroll are only on the client side. You can regenerate each of your entities, but when Yeoman asks if you want to overwrite preexisting files, press n to choose no for every file except the AngularJS router, controller, and 'entities' list html. This should allow you to implement pagination with minimal impact.

You can regenerate your entities by changing "pagination": "infinite-scroll" to "pagination": "pagination" in your entity JSONs under .jhipster then re-running yo jhipster:entity entityName.

Upvotes: 13

Related Questions