@memberjunction/ng-query-grid 2.32.2 → 2.34.0

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.
Files changed (2) hide show
  1. package/README.md +239 -0
  2. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,239 @@
1
+ # Query Grid Component
2
+
3
+ An Angular grid component for displaying and interacting with data from any MemberJunction query. This component provides a flexible way to display query results in a feature-rich grid with pagination, sorting, and Excel export capabilities.
4
+
5
+ ## Features
6
+
7
+ - **Query-Based Data Display**: Show results from any MemberJunction query
8
+ - **Pagination**: Built-in pagination with configurable page size
9
+ - **Virtual Scrolling**: Efficient handling of large datasets
10
+ - **Excel Export**: One-click export to Excel
11
+ - **Sorting and Reordering**: Sort columns and reorder them via drag and drop
12
+ - **Row Selection**: Select rows for further operations
13
+ - **Responsive Layout**: Automatically adjusts to container size
14
+ - **Event Handling**: Row click events for interactive applications
15
+ - **Loading States**: Visual feedback during data fetching
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @memberjunction/ng-query-grid
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Import the Module
26
+
27
+ ```typescript
28
+ import { QueryGridModule } from '@memberjunction/ng-query-grid';
29
+
30
+ @NgModule({
31
+ imports: [
32
+ QueryGridModule,
33
+ // other imports
34
+ ],
35
+ // ...
36
+ })
37
+ export class YourModule { }
38
+ ```
39
+
40
+ ### Basic Component Usage
41
+
42
+ ```html
43
+ <!-- Basic query grid with default settings -->
44
+ <mj-query-grid
45
+ [Params]="queryParams"
46
+ (rowClicked)="onRowClicked($event)">
47
+ </mj-query-grid>
48
+ ```
49
+
50
+ ### With Configuration Options
51
+
52
+ ```html
53
+ <!-- Configured query grid -->
54
+ <mj-query-grid
55
+ [Params]="queryParams"
56
+ [BottomMargin]="20"
57
+ [AutoNavigate]="false"
58
+ [AllowLoad]="isAllowedToLoad"
59
+ (rowClicked)="onRowClicked($event)">
60
+ </mj-query-grid>
61
+ ```
62
+
63
+ ### TypeScript Component Example
64
+
65
+ ```typescript
66
+ import { Component, OnInit } from '@angular/core';
67
+ import { RunQueryParams } from '@memberjunction/core';
68
+ import { GridRowClickedEvent } from '@memberjunction/ng-query-grid';
69
+
70
+ @Component({
71
+ selector: 'app-sales-dashboard',
72
+ template: `
73
+ <h2>Sales Query Results</h2>
74
+
75
+ <div class="query-controls">
76
+ <button kendoButton (click)="refreshData()">Refresh Data</button>
77
+ <button kendoButton (click)="toggleAutoNavigate()">
78
+ {{ autoNavigate ? 'Disable' : 'Enable' }} Auto Navigation
79
+ </button>
80
+ </div>
81
+
82
+ <div class="query-container">
83
+ <mj-query-grid
84
+ [Params]="salesQueryParams"
85
+ [AutoNavigate]="autoNavigate"
86
+ (rowClicked)="onSalesRowClicked($event)">
87
+ </mj-query-grid>
88
+ </div>
89
+
90
+ <div *ngIf="selectedRow">
91
+ <h3>Selected Order Details</h3>
92
+ <p>Order ID: {{ getOrderId() }}</p>
93
+ <p>Customer: {{ getCustomerName() }}</p>
94
+ <p>Amount: {{ getOrderAmount() | currency }}</p>
95
+ </div>
96
+ `,
97
+ styles: [`
98
+ .query-container {
99
+ height: 600px;
100
+ margin-bottom: 20px;
101
+ }
102
+ .query-controls {
103
+ margin-bottom: 10px;
104
+ }
105
+ button {
106
+ margin-right: 10px;
107
+ }
108
+ `]
109
+ })
110
+ export class SalesDashboardComponent implements OnInit {
111
+ salesQueryParams: RunQueryParams;
112
+ autoNavigate = true;
113
+ selectedRow: GridRowClickedEvent | null = null;
114
+
115
+ constructor() {
116
+ // Initialize query parameters
117
+ this.salesQueryParams = {
118
+ QueryID: 'SalesOrdersSummary',
119
+ Parameters: [
120
+ { Name: 'StartDate', Value: '2023-01-01' },
121
+ { Name: 'EndDate', Value: '2023-12-31' }
122
+ ]
123
+ };
124
+ }
125
+
126
+ ngOnInit() {
127
+ // Additional initialization if needed
128
+ }
129
+
130
+ refreshData() {
131
+ // Get a reference to the grid and refresh it
132
+ const grid = document.querySelector('mj-query-grid') as any;
133
+ if (grid) {
134
+ grid.RefreshFromSavedParams();
135
+ }
136
+ }
137
+
138
+ toggleAutoNavigate() {
139
+ this.autoNavigate = !this.autoNavigate;
140
+ }
141
+
142
+ onSalesRowClicked(event: GridRowClickedEvent) {
143
+ console.log('Row clicked:', event);
144
+ this.selectedRow = event;
145
+
146
+ // If auto-navigate is enabled, you could navigate to a detail page
147
+ if (this.autoNavigate) {
148
+ const orderId = this.getOrderId();
149
+ // this.router.navigate(['/orders', orderId]);
150
+ }
151
+ }
152
+
153
+ getOrderId(): string {
154
+ return this.selectedRow?.KeyValuePairs.find(kvp => kvp.Key === 'OrderID')?.Value || '';
155
+ }
156
+
157
+ getCustomerName(): string {
158
+ return this.selectedRow?.KeyValuePairs.find(kvp => kvp.Key === 'CustomerName')?.Value || '';
159
+ }
160
+
161
+ getOrderAmount(): number {
162
+ const amount = this.selectedRow?.KeyValuePairs.find(kvp => kvp.Key === 'TotalAmount')?.Value;
163
+ return amount ? parseFloat(amount) : 0;
164
+ }
165
+ }
166
+ ```
167
+
168
+ ## API Reference
169
+
170
+ ### Inputs
171
+
172
+ - `Params`: RunQueryParams - Parameters for running the query
173
+ - `BottomMargin`: number - Bottom margin in pixels (default: 0)
174
+ - `InEditMode`: boolean - Whether the grid is in edit mode (default: false)
175
+ - `EditMode`: "None" | "Save" | "Queue" - Edit mode type (default: "None")
176
+ - `AutoNavigate`: boolean - Whether to auto-navigate on row click (default: true)
177
+ - `AllowLoad`: boolean - Whether to allow loading data (default: true)
178
+
179
+ ### Outputs
180
+
181
+ - `rowClicked`: EventEmitter<GridRowClickedEvent> - Emitted when a row is clicked
182
+
183
+ ### Methods
184
+
185
+ - `Refresh(params: RunQueryParams)`: Refreshes the grid data with the given query parameters
186
+ - `RefreshFromSavedParams()`: Refreshes the grid data using the previously saved parameters
187
+ - `doExcelExport()`: Exports the current grid data to Excel
188
+
189
+ ### Types
190
+
191
+ ```typescript
192
+ export type GridRowClickedEvent = {
193
+ entityId: number;
194
+ entityName: string;
195
+ KeyValuePairs: KeyValuePair[];
196
+ }
197
+ ```
198
+
199
+ ## Query Parameters
200
+
201
+ The component accepts a `RunQueryParams` object that specifies which query to run:
202
+
203
+ ```typescript
204
+ const queryParams: RunQueryParams = {
205
+ QueryID: 'MyQueryID', // ID of the query to run
206
+ Parameters: [ // Optional query parameters
207
+ { Name: 'Param1', Value: 'Value1' },
208
+ { Name: 'Param2', Value: 42 }
209
+ ],
210
+ MaxRows: 1000 // Optional maximum rows to return
211
+ };
212
+ ```
213
+
214
+ ## Excel Export
215
+
216
+ The component includes built-in Excel export functionality. Users can click the Excel export button in the grid toolbar to download the current data as an Excel file. The file will be named based on the QueryID (e.g., "MyQueryID_Query.xlsx").
217
+
218
+ ## Grid Features
219
+
220
+ The grid component leverages Kendo UI Grid and includes the following features:
221
+
222
+ - Virtual scrolling for performance with large datasets
223
+ - Column resizing, reordering, and sorting
224
+ - Row selection
225
+ - Pagination with configurable page size
226
+ - Loading indicator during data fetch
227
+ - Responsive design that fills its container
228
+
229
+ ## Styling
230
+
231
+ The component uses Kendo UI Grid component styles and includes basic CSS that can be overridden in your application.
232
+
233
+ ## Dependencies
234
+
235
+ - `@memberjunction/core`: For metadata and query execution
236
+ - `@memberjunction/core-entities`: For entity types
237
+ - `@memberjunction/global`: For global utilities
238
+ - `@progress/kendo-angular-grid`: For the grid component
239
+ - `@progress/kendo-angular-excel-export`: For Excel export functionality
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-query-grid",
3
- "version": "2.32.2",
3
+ "version": "2.34.0",
4
4
  "description": "MemberJunction: Angular Grid to display any MemberJunction Query",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -28,12 +28,12 @@
28
28
  "@progress/kendo-angular-dialog": "16.2.0"
29
29
  },
30
30
  "dependencies": {
31
- "@memberjunction/core-entities": "2.32.2",
32
- "@memberjunction/global": "2.32.2",
33
- "@memberjunction/core": "2.32.2",
34
- "@memberjunction/ng-container-directives": "2.32.2",
35
- "@memberjunction/ng-compare-records": "2.32.2",
36
- "@memberjunction/ng-shared": "2.32.2",
31
+ "@memberjunction/core-entities": "2.34.0",
32
+ "@memberjunction/global": "2.34.0",
33
+ "@memberjunction/core": "2.34.0",
34
+ "@memberjunction/ng-container-directives": "2.34.0",
35
+ "@memberjunction/ng-compare-records": "2.34.0",
36
+ "@memberjunction/ng-shared": "2.34.0",
37
37
  "tslib": "^2.3.0"
38
38
  },
39
39
  "sideEffects": false