diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java index e51c880a..0d7e338c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/demo/controller/DemoTableController.java @@ -6,6 +6,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -140,6 +141,16 @@ public class DemoTableController extends BaseController return prefix + "/button"; } + /** + * 直接加载表格数据 + */ + @GetMapping("/data") + public String data(ModelMap mmap) + { + mmap.put("users", users); + return prefix + "/data"; + } + /** * 表格冻结列 */ @@ -166,7 +177,7 @@ public class DemoTableController extends BaseController { return prefix + "/detail"; } - + /** * 表格父子视图 */ diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 17e0cd05..e651baaa 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -122,6 +122,7 @@ var table = { queryParams: options.queryParams, // 传递参数(*) rowStyle: options.rowStyle, // 通过自定义函数设置行样式 columns: options.columns, // 显示列信息(*) + data: options.data, // 被加载的数据 responseHandler: $.table.responseHandler, // 在加载服务器发送来的数据之前处理函数 onLoadSuccess: $.table.onLoadSuccess, // 当所有数据被加载时触发处理函数 exportOptions: options.exportOptions, // 前端导出忽略列索引 diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/data.html b/ruoyi-admin/src/main/resources/templates/demo/table/data.html new file mode 100644 index 00000000..818d5b7d --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/demo/table/data.html @@ -0,0 +1,76 @@ + + +
+