简体   繁体   English

JHipster 如何将视图从实体更改为可分页

[英]JHipster how to change the view from an entity to Pageable

I am looking for the easiest way for including Pagination for one of the entities I have created with the help of JDL Studio which JHipster provides.我正在寻找最简单的方法来为我在 JHipster 提供的 JDL Studio 的帮助下创建的实体之一包含分页。 I have not chosen the Pagination option in the jdl file as I do not need Pagination in general, only for one entity.我没有在 jdl 文件中选择分页选项,因为我一般不需要分页,只需要一个实体。 How can I make this change manually?如何手动进行此更改?

The below JDL shows how you can specify pagination for one entity.下面的 JDL 显示了如何为一个实体指定分页。 Entity A will be the only entity with pagination实体 A 将是唯一具有分页的实体

entity A {
    name String required
}

entity B {}

entity C {}

paginate A with pagination

For more information on declaring options in JDL, see the official docs .有关在 JDL 中声明选项的更多信息,请参阅官方文档

Following are the steps to add pagination to the existing entity which does not have existing pagination.以下是向没有现有分页的现有实体添加分页的步骤。

  1. Change "pagination" option更改"pagination"选项
    You can do this by changing by "pagination": "no" to "pagination": true from EntityName.json file from ./ProjectName/.jhipster directory.您可以通过将./ProjectName/.jhipster目录中的EntityName.json文件中的"pagination": "no"更改为"pagination": true./ProjectName/.jhipster
  2. Update JDL file xxx.jh更新 JDL 文件 xxx.jh
 entity Company{ name String } entity Employee{ empName String } paginate Employee with pagination

I want pagination for Employees only so I have updated paginate Employee with pagination我只想为员工分页,所以我更新了paginate Employee with pagination
3. Import entities by using, 3.通过使用导入实体,
jhipster import-jdl xxx.jh

After successful import, the impact will be on both the server and client side.导入成功后,对服务端和客户端都有影响。
On the server side mainly EntityNameResource.java and EntityNameService.java will change.在服务器端主要EntityNameResource.javaEntityNameService.java会发生变化。
On the client side EntityName.component.html, multiple supporting.ts files will change.在客户端EntityName.component.html 上,多个supporting.ts 文件会发生变化。

1- go to: 1-去:

/{projectRoot}/.jhipster/YourEntity.json

2- Find And set pagination property like this: 2- 查找并设置分页属性,如下所示:

From

"pagination": "no",

To

"pagination": "pagination",

3- open a prompt and type: 3-打开提示并键入:

jhipster entity [entityName]

This ask you to reload your entity you can choose "regerate" or "update" (and more options) for your entity.这要求您重新加载您的实体,您可以为您的实体选择“重新生成”或“更新”(以及更多选项)。

This should implement all pagination system.这应该实现所有分页系统。

Tested in Jhipster 6.8.0在 Jhipster 6.8.0 中测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM