强大且可自定义 jQuery数据表/网格插件 supergrid.js

  • 源码大小:22.81KB
  • 所需积分:1积分
  • 源码编号:19JP-3133
  • 浏览次数:761次
  • 最后更新:2023年05月09日
  • 所属栏目:表格
本站默认解压密码:19jp.com 或 19jp_com

简介

supergrid.js是一个功能强大、灵活且可自定义的数据表/网格jQuery插件,用于在网页上操作和显示表格数据。

主要功能:

  • 同时支持Bootstrap 5和jQuery UI主题。
  • 从对象数组中加载表格数据。
  • 将表头固定到顶部。
  • 将特定数量的表列固定在左侧。
  • 完全可自定义的分页控件。
  • 一个方便的基于复选框的系统,用于选择多行。
  • 可调整表列的大小。
  • 还有更多。

如何使用它:

1.在文档中加载必要的jQuery库、Bootstrap 5框架(或jQuery UI)和Font Awesome 6标志性字体。

  1. <!-- jQuery is required -->
  2. <script src="/path/to/cdn/jquery.min.js"></script>
  3.  
  4. <!-- Bootstrap 5 -->
  5. <link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
  6. <script src="/path/to/cdn/bootstrap.bundle.min.js"></script>
  7.  
  8. <!-- Font Awesome 6 -->
  9. <link rel="stylesheet" href="/path/to/cdn/all.min.css" />

2.在页面上创建一个空表。

  1. <table id="example"></table>

3.准备表格数据。

  1. const data = [
  2. {
  3. id:0,
  4. name:"jQueryScript",
  5. age: "26",
  6. gender:"male",
  7. dob: "18/03/1997",
  8. // ...
  9. },
  10. // ...
  11. ]

4.初始化插件,并根据您提供的数据生成一个基本数据表。

  1. $("#example").superGrid({
  2. data: Data,
  3. colModel:[
  4. {
  5. name: "name",
  6. label: "Full Name",
  7. width: "150",
  8. resizable: true,
  9. },
  10. {
  11. name:"age",
  12. label:"Age",
  13. colDataType:"form",
  14. // text
  15. // number
  16. // radio
  17. // checkbox
  18. // password
  19. // date
  20. // time
  21. // textarea
  22. formInputType:"date",
  23. },
  24. {
  25. name: "gender",
  26. label: "Gender",
  27. colDataType: "form",
  28. formInputType: "select",
  29. selectOptions: ["Male", "Female","Others"]
  30. },
  31. {
  32. name:"dob",
  33. label:"Date of Birth",
  34. hidden: true
  35. },
  36. // ...
  37. ]
  38. });

5.完整的插件选项。

  1. $("#example").superGrid({
  2.  
  3. // or 'jqueryui'
  4. theme: "bootstrap5",
  5.  
  6. // text to display when no results
  7. defaultMsg: "Nothing to show...",
  8. // sticky table header
  9. stickyHeader: true,
  10.  
  11. // sticky table columns
  12. stickyCols: 0,
  13.  
  14. // shows a scroller for wider table
  15. scroller: false,
  16. scrollSpeed: 100,
  17.  
  18. // enable pagination controls
  19. pager: true,
  20.  
  21. // number of rows to display per page
  22. rowsPerPage: 20,
  23.  
  24. // number the rows across the table
  25. rowNumbering: true,
  26.  
  27. // enable multiselect
  28. multiSelect: false,
  29.  
  30. });

预览截图