cypress-ag-grid 3.3.1 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/data.json CHANGED
@@ -1,22 +1,22 @@
1
1
  [
2
- { "year": "2020", "make": "Toyota", "model": "Celica", "condition": "fair", "price": "35000" },
3
- { "year": "2020", "make": "Ford", "model": "Mondeo", "condition":"excellent", "price": "32000" },
4
- { "year": "2020", "make": "Porsche", "model": "Boxter", "condition": "good", "price": "72000" },
5
- { "year": "2020", "make": "BMW", "model": "3-series", "condition": "fair", "price": "45000" },
6
- { "year": "2020", "make": "Mercedes", "model": "GLC300", "condition": "good","price": "53000" },
7
- { "year": "2020", "make": "Honda", "model": "Civic", "condition": "poor", "price": "22000" },
8
- { "year": "2020", "make": "Honda", "model": "Accord", "condition": "poor", "price": "32000" },
9
- { "year": "2020", "make": "Ford", "model": "Taurus", "condition":"excellent","price": "19000" },
10
- { "year": "2020", "make": "Hyundai", "model": "Elantra", "condition":"good","price": "22000" },
11
- { "year": "2020", "make": "Toyota", "model": "Celica", "condition":"poor","price": "5000" },
12
- { "year": "2020", "make": "Ford", "model": "Mondeo", "condition":"good","price": "25000" },
13
- { "year": "2020", "make": "Porsche", "model": "Boxter", "condition":"good","price": "99000" },
14
- { "year": "2020", "make": "BMW", "model": "3-series", "condition":"poor","price": "32000" },
15
- { "year": "2020", "make": "Mercedes", "model": "GLC300", "condition":"excellent","price": "35000" },
16
- { "year": "2011", "make": "Honda", "model": "Civic", "condition":"good","price": "9000" },
17
- { "year": "2020", "make": "Honda", "model": "Accord", "condition":"good","price": "34000" },
18
- { "year": "1990", "make": "Ford", "model": "Taurus", "condition":"excellent","price": "900" },
19
- { "year": "2020", "make": "Hyundai", "model": "Elantra", "condition":"fair","price": "3000" },
20
- { "year": "2020", "make": "BMW", "model": "2002", "condition":"excellent","price": "88001" },
21
- { "year": "2023", "make": "Hyundai", "model": "Santa Fe", "condition":"excellent","price": "" }
22
- ]
2
+ { "year": "2020", "make": "Toyota", "model": "Celica", "condition": "fair", "mileage": 12000, "price": "35000" },
3
+ { "year": "2020", "make": "Ford", "model": "Mondeo", "condition":"excellent", "mileage": 8000, "price": "32000" },
4
+ { "year": "2020", "make": "Porsche", "model": "Boxter", "condition": "good", "mileage": 30000, "price": "72000" },
5
+ { "year": "2020", "make": "BMW", "model": "3-series", "condition": "fair", "mileage": 18000, "price": "45000" },
6
+ { "year": "2020", "make": "Mercedes", "model": "GLC300", "condition": "good","mileage": 24000, "price": "53000" },
7
+ { "year": "2020", "make": "Honda", "model": "Civic", "condition": "poor", "mileage": 40000, "price": "22000" },
8
+ { "year": "2020", "make": "Honda", "model": "Accord", "condition": "poor", "mileage": 42000, "price": "32000" },
9
+ { "year": "2020", "make": "Ford", "model": "Taurus", "condition":"excellent","mileage": 5000, "price": "19000" },
10
+ { "year": "2020", "make": "Hyundai", "model": "Elantra", "condition":"good","mileage": 28000, "price": "22000" },
11
+ { "year": "2020", "make": "Toyota", "model": "Celica", "condition":"poor","mileage": 60000, "price": "5000" },
12
+ { "year": "2020", "make": "Ford", "model": "Mondeo", "condition":"good","mileage": 15000, "price": "25000" },
13
+ { "year": "2020", "make": "Porsche", "model": "Boxter", "condition":"good","mileage": 1000, "price": "99000" },
14
+ { "year": "2020", "make": "BMW", "model": "3-series", "condition":"poor","mileage": 52000, "price": "32000" },
15
+ { "year": "2020", "make": "Mercedes", "model": "GLC300", "condition":"excellent","mileage": 9000, "price": "35000" },
16
+ { "year": "2011", "make": "Honda", "model": "Civic", "condition":"good","mileage": 70000, "price": "9000" },
17
+ { "year": "2020", "make": "Honda", "model": "Accord", "condition":"good","mileage": 22000, "price": "34000" },
18
+ { "year": "1990", "make": "Ford", "model": "Taurus", "condition":"excellent","mileage": 90000, "price": "900" },
19
+ { "year": "2020", "make": "Hyundai", "model": "Elantra", "condition":"fair","mileage": 3500, "price": "3000" },
20
+ { "year": "2020", "make": "BMW", "model": "2002", "condition":"excellent","mileage": 4500, "price": "88001" },
21
+ { "year": "2023", "make": "Hyundai", "model": "Santa Fe", "condition":"excellent","mileage": 250, "price": "" }
22
+ ]
package/app/grid-basic.js CHANGED
@@ -1,18 +1,51 @@
1
+ function getRowDataUrl() {
2
+ return window.AG_GRID_DATA_PATH || "./data.json";
3
+ }
4
+
1
5
  // specify the columns
2
- const columnDefs = [
3
- { field: "year", pinned: "left" },
4
- { field: "make", rowGroup: false, pinned: "left" },
5
- { field: "model", filter: true },
6
- { field: "condition",filter: "agTextColumnFilter", filterParams: { numAlwaysVisibleConditions: 2, defaultJoinOperator: 'OR', } },
7
- {
8
- field: "price",
9
- pinned: "right",
10
- floatingFilter: false,
11
- sortable: false,
12
- editable: true,
13
- cellEditor: "agTextCellEditor",
14
- },
15
- ];
6
+ function getColumnDefs(floatingFilter) {
7
+ return [
8
+ { field: "year", pinned: "left", floatingFilter },
9
+ { field: "make", rowGroup: false, pinned: "left", floatingFilter },
10
+ { field: "model", filter: true, floatingFilter },
11
+ { field: "condition", filter: "agTextColumnFilter", floatingFilter, filterParams: { numAlwaysVisibleConditions: 2, defaultJoinOperator: 'OR', } },
12
+ {
13
+ field: "mileage",
14
+ filter: "agNumberColumnFilter",
15
+ floatingFilter: false,
16
+ hide: true,
17
+ },
18
+ {
19
+ field: "price",
20
+ pinned: "right",
21
+ floatingFilter: false,
22
+ sortable: false,
23
+ editable: true,
24
+ cellEditor: "agTextCellEditor",
25
+ },
26
+ ];
27
+ }
28
+
29
+ function isAgGridVersion35OrLater() {
30
+ const majorVersion = Number((window.AG_GRID_LIBRARY_VERSION || "0").split(".")[0]);
31
+ return majorVersion >= 35;
32
+ }
33
+
34
+ function applyColumnDefs(columnDefs) {
35
+ if (!gridOptions.api) {
36
+ return;
37
+ }
38
+
39
+ if (!isAgGridVersion35OrLater() && typeof gridOptions.api.setColumnDefs === "function") {
40
+ gridOptions.api.setColumnDefs(columnDefs);
41
+ } else {
42
+ gridOptions.api.setGridOption("columnDefs", columnDefs);
43
+ }
44
+
45
+ if (window.Cypress) {
46
+ gridOptions.api.sizeColumnsToFit();
47
+ }
48
+ }
16
49
 
17
50
  const autoGroupColumnDef = {
18
51
  headerName: "Model",
@@ -38,7 +71,7 @@ const gridOptions = {
38
71
  },
39
72
  autoGroupColumnDef: autoGroupColumnDef,
40
73
  groupSelectsChildren: true,
41
- columnDefs: columnDefs,
74
+ columnDefs: getColumnDefs(true),
42
75
  rowSelection: "multiple",
43
76
  domLayout: "normal",
44
77
  pagination: true,
@@ -46,14 +79,46 @@ const gridOptions = {
46
79
  sideBar: true,
47
80
  };
48
81
 
82
+ if (isAgGridVersion35OrLater()) {
83
+ gridOptions.paginationPageSizeSelector = [5, 10, 20];
84
+ }
85
+
49
86
  // lookup the container we want the Grid to use
50
87
  const eGridDiv = document.querySelector("#myGrid");
51
88
 
89
+ function MakeFloating(floating) {
90
+ applyColumnDefs(getColumnDefs(floating));
91
+ }
92
+
93
+ function setColumnFilter(field, filter, floatingFilter = true, hide) {
94
+ const columnDefs = gridOptions.api.getColumnDefs().map((columnDef) => {
95
+ if (columnDef.field !== field) {
96
+ return columnDef;
97
+ }
98
+
99
+ const updatedColumnDef = {
100
+ ...columnDef,
101
+ filter,
102
+ floatingFilter,
103
+ };
104
+
105
+ if (hide !== undefined) {
106
+ updatedColumnDef.hide = hide;
107
+ }
108
+
109
+ return updatedColumnDef;
110
+ });
111
+
112
+ applyColumnDefs(columnDefs);
113
+ }
114
+
52
115
  // create the grid passing in the div to use together with the columns & data we want to use
53
- new agGrid.Grid(eGridDiv, gridOptions);
116
+ const gridApi = agGrid.createGrid(eGridDiv, gridOptions);
117
+ // keep backward compatibility with code that references gridOptions.api
118
+ gridOptions.api = gridApi;
54
119
 
55
120
  // Grab the grid data from the supplied API endpoint
56
- fetch("./data.json")
121
+ fetch(getRowDataUrl())
57
122
  .then(res => res.json())
58
123
  .then((data) => {
59
124
  gridOptions.api.setGridOption('rowData', data);
@@ -61,7 +126,7 @@ fetch("./data.json")
61
126
 
62
127
  function autoSizeAllColumns() {
63
128
  var allColumnIds = [];
64
- gridOptions.api.getAllColumns().forEach(function (column) {
129
+ gridOptions.api.getColumns().forEach(function (column) {
65
130
  allColumnIds.push(column.colId);
66
131
  });
67
132
  gridOptions.api.autoSizeColumns(allColumnIds);
@@ -1,9 +1,13 @@
1
+ function getRowDataUrl() {
2
+ return window.AG_GRID_DATA_PATH || "./data.json";
3
+ }
4
+
1
5
  // specify the columns
2
6
  const columnDefsGrouped = [
3
7
  { field: "year", pivot: true, },
4
8
  { field: "make", rowGroup: true, enableRowGroup: true },
5
9
  { field: "model", filter: true },
6
- { field: "price", editable: true, cellEditor: 'agTextCellEditor' },
10
+ { field: "price", editable: true, cellEditor: 'agTextCellEditor' },
7
11
  ];
8
12
 
9
13
  const autoGroupColumnDefGrouped = {
@@ -43,10 +47,12 @@ const gridOptionsGrouped = {
43
47
  const eGridDivGrouped = document.querySelector("#myGrid2");
44
48
 
45
49
  // create the grid passing in the div to use together with the columns & data we want to use
46
- new agGrid.Grid(eGridDivGrouped, gridOptionsGrouped);
50
+ const gridApiGrouped = agGrid.createGrid(eGridDivGrouped, gridOptionsGrouped);
51
+ // keep backward compatibility with code that references gridOptionsGrouped.api
52
+ gridOptionsGrouped.api = gridApiGrouped;
47
53
 
48
54
  // Grab the grid data from the supplied API endpoint
49
- fetch("./data.json")
55
+ fetch(getRowDataUrl())
50
56
  .then(res => res.json())
51
57
  .then((data) => {
52
58
  gridOptionsGrouped.api.setGridOption('rowData', data);
@@ -54,7 +60,7 @@ fetch("./data.json")
54
60
 
55
61
  function autoSizeAllColumns() {
56
62
  var allColumnIds = [];
57
- gridOptionsGrouped.api.getAllColumns().forEach(function (column) {
63
+ gridOptionsGrouped.api.getColumns().forEach(function (column) {
58
64
  allColumnIds.push(column.colId);
59
65
  });
60
66
  gridOptionsGrouped.api.autoSizeColumns(allColumnIds);
@@ -64,6 +70,6 @@ function autoSizeAllColumns() {
64
70
  if (window.Cypress) {
65
71
  gridOptionsGrouped.api.sizeColumnsToFit();
66
72
  } else {
67
- // Otherwise auto-size columns the way we wish to view the grid in production.
68
- autoSizeAllColumns();
73
+ // Otherwise auto-size columns the way we wish to view the grid in production.
74
+ autoSizeAllColumns();
69
75
  }
package/app/index.html CHANGED
@@ -1,15 +1,62 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
+
3
4
  <head>
4
- <script src="https://unpkg.com/ag-grid-enterprise/dist/ag-grid-enterprise.min.noStyle.js"></script>
5
+ <meta charset="utf-8">
6
+ <title>AG Grid Cypress Example v35</title>
7
+ <script>
8
+ window.AG_GRID_EXAMPLE_VERSION = "v35";
9
+ window.AG_GRID_LIBRARY_VERSION = "35.0.0";
10
+ window.AG_GRID_DATA_PATH = "./data.json";
11
+ </script>
12
+ <script src="https://unpkg.com/ag-grid-enterprise@35.0.0/dist/ag-grid-enterprise.min.noStyle.js"></script>
5
13
  <link rel="stylesheet" href="./ag-grid.css">
6
14
  <link rel="stylesheet" href="./ag-theme-alpine.css">
15
+ <style>
16
+ body {
17
+ font-family: Arial, sans-serif;
18
+ margin: 16px;
19
+ }
20
+
21
+ .example-header {
22
+ align-items: center;
23
+ display: flex;
24
+ gap: 12px;
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ .example-version {
29
+ border: 1px solid #1f4d8f;
30
+ border-radius: 999px;
31
+ color: #1f4d8f;
32
+ font-size: 14px;
33
+ font-weight: 700;
34
+ padding: 4px 10px;
35
+ }
36
+
37
+ .example-links a {
38
+ color: #1f4d8f;
39
+ margin-right: 12px;
40
+ }
41
+ </style>
7
42
  </head>
43
+
8
44
  <body>
45
+ <div class="example-header">
46
+ <h1>AG Grid Cypress Example</h1>
47
+ <span class="example-version">AG Grid v35</span>
48
+ <nav class="example-links">
49
+ <a href="./index.html">v35</a>
50
+ <a href="./v34/index.html">v34</a>
51
+ <a href="./v33/index.html">v33</a>
52
+ </nav>
53
+ </div>
9
54
  <div id="myGrid" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
10
55
  <script src="grid-basic.js" type="text/javascript" charset="utf-8"></script>
11
-
56
+ <button onclick="MakeFloating(true)" id="floating">Floating</button>
57
+ <button onclick="MakeFloating(false)" id="nonFloating">Non Floating</button>
12
58
  <div id="myGrid2" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
13
59
  <script src="grid-grouped.js" type="text/javascript" charset="utf-8"></script>
14
60
  </body>
15
- </html>
61
+
62
+ </html>
@@ -0,0 +1,62 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>AG Grid Cypress Example v33</title>
7
+ <script>
8
+ window.AG_GRID_EXAMPLE_VERSION = "v33";
9
+ window.AG_GRID_LIBRARY_VERSION = "33.0.0";
10
+ window.AG_GRID_DATA_PATH = "../data.json";
11
+ </script>
12
+ <script src="https://unpkg.com/ag-grid-enterprise@33.0.0/dist/ag-grid-enterprise.min.noStyle.js"></script>
13
+ <link rel="stylesheet" href="../ag-grid.css">
14
+ <link rel="stylesheet" href="../ag-theme-alpine.css">
15
+ <style>
16
+ body {
17
+ font-family: Arial, sans-serif;
18
+ margin: 16px;
19
+ }
20
+
21
+ .example-header {
22
+ align-items: center;
23
+ display: flex;
24
+ gap: 12px;
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ .example-version {
29
+ border: 1px solid #1b5e20;
30
+ border-radius: 999px;
31
+ color: #1b5e20;
32
+ font-size: 14px;
33
+ font-weight: 700;
34
+ padding: 4px 10px;
35
+ }
36
+
37
+ .example-links a {
38
+ color: #1b5e20;
39
+ margin-right: 12px;
40
+ }
41
+ </style>
42
+ </head>
43
+
44
+ <body>
45
+ <div class="example-header">
46
+ <h1>AG Grid Cypress Example</h1>
47
+ <span class="example-version">AG Grid v33</span>
48
+ <nav class="example-links">
49
+ <a href="../index.html">v35</a>
50
+ <a href="../v34/index.html">v34</a>
51
+ <a href="./index.html">v33</a>
52
+ </nav>
53
+ </div>
54
+ <div id="myGrid" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
55
+ <script src="../grid-basic.js" type="text/javascript" charset="utf-8"></script>
56
+ <button onclick="MakeFloating(true)" id="floating">Floating</button>
57
+ <button onclick="MakeFloating(false)" id="nonFloating">Non Floating</button>
58
+ <div id="myGrid2" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
59
+ <script src="../grid-grouped.js" type="text/javascript" charset="utf-8"></script>
60
+ </body>
61
+
62
+ </html>
@@ -0,0 +1,62 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>AG Grid Cypress Example v34</title>
7
+ <script>
8
+ window.AG_GRID_EXAMPLE_VERSION = "v34";
9
+ window.AG_GRID_LIBRARY_VERSION = "34.0.0";
10
+ window.AG_GRID_DATA_PATH = "../data.json";
11
+ </script>
12
+ <script src="https://unpkg.com/ag-grid-enterprise@34.0.0/dist/ag-grid-enterprise.min.noStyle.js"></script>
13
+ <link rel="stylesheet" href="../ag-grid.css">
14
+ <link rel="stylesheet" href="../ag-theme-alpine.css">
15
+ <style>
16
+ body {
17
+ font-family: Arial, sans-serif;
18
+ margin: 16px;
19
+ }
20
+
21
+ .example-header {
22
+ align-items: center;
23
+ display: flex;
24
+ gap: 12px;
25
+ margin-bottom: 16px;
26
+ }
27
+
28
+ .example-version {
29
+ border: 1px solid #7b341e;
30
+ border-radius: 999px;
31
+ color: #7b341e;
32
+ font-size: 14px;
33
+ font-weight: 700;
34
+ padding: 4px 10px;
35
+ }
36
+
37
+ .example-links a {
38
+ color: #7b341e;
39
+ margin-right: 12px;
40
+ }
41
+ </style>
42
+ </head>
43
+
44
+ <body>
45
+ <div class="example-header">
46
+ <h1>AG Grid Cypress Example</h1>
47
+ <span class="example-version">AG Grid v34</span>
48
+ <nav class="example-links">
49
+ <a href="../index.html">v35</a>
50
+ <a href="./index.html">v34</a>
51
+ <a href="../v33/index.html">v33</a>
52
+ </nav>
53
+ </div>
54
+ <div id="myGrid" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
55
+ <script src="../grid-basic.js" type="text/javascript" charset="utf-8"></script>
56
+ <button onclick="MakeFloating(true)" id="floating">Floating</button>
57
+ <button onclick="MakeFloating(false)" id="nonFloating">Non Floating</button>
58
+ <div id="myGrid2" style="height: 600px;width:900px;" class="ag-theme-alpine" sideBar="true"></div>
59
+ <script src="../grid-grouped.js" type="text/javascript" charset="utf-8"></script>
60
+ </body>
61
+
62
+ </html>
@@ -0,0 +1,6 @@
1
+ import { runAgGridDataSuite } from "./shared/run-ag-grid-data-suite";
2
+
3
+ runAgGridDataSuite({
4
+ pagePath: "../app/v33/index.html",
5
+ versionLabel: "v33",
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runAgGridDataSuite } from "./shared/run-ag-grid-data-suite";
2
+
3
+ runAgGridDataSuite({
4
+ pagePath: "../app/v34/index.html",
5
+ versionLabel: "v34",
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runAgGridDataSuite } from "./shared/run-ag-grid-data-suite";
2
+
3
+ runAgGridDataSuite({
4
+ pagePath: "../app/index.html",
5
+ versionLabel: "v35",
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runAgGridElementsSuite } from "./shared/run-ag-grid-elements-suite";
2
+
3
+ runAgGridElementsSuite({
4
+ pagePath: "../app/v33/index.html",
5
+ versionLabel: "v33",
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runAgGridElementsSuite } from "./shared/run-ag-grid-elements-suite";
2
+
3
+ runAgGridElementsSuite({
4
+ pagePath: "../app/v34/index.html",
5
+ versionLabel: "v34",
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runAgGridElementsSuite } from "./shared/run-ag-grid-elements-suite";
2
+
3
+ runAgGridElementsSuite({
4
+ pagePath: "../app/index.html",
5
+ versionLabel: "v35",
6
+ });