File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,23 @@ class View {
156156 }
157157 }
158158
159+ /**
160+ * Returns a Promise that resolves to an array of unique values contained in
161+ * the provided column index.
162+ *
163+ * @param columnIndex - The index to retrieve unique values for.
164+ */
165+ async uniqueValues ( region : DataModel . CellRegion , columnIndex : number ) : Promise < any [ ] > {
166+ return new Promise ( ( resolve , reject ) => {
167+ const columnName = this . metadata ( region , 0 , columnIndex ) [ 'name' ] ;
168+ let uniqueVals = new Set ( ) ;
169+ for ( let row of this . dataset ) {
170+ uniqueVals . add ( row [ columnName ] ) ;
171+ } ;
172+ resolve ( Array . from ( uniqueVals ) ) ;
173+ } ) ;
174+ }
175+
159176 private readonly _data : View . DataSource ;
160177 private readonly _bodyFields : ViewBasedJSONModel . IField [ ] ;
161178 private readonly _headerFields : ViewBasedJSONModel . IField [ ] ;
Original file line number Diff line number Diff line change @@ -335,6 +335,7 @@ export class ViewBasedJSONModel extends MutableDataModel {
335335 * Returns a Promise that resolves to an array of unique values contained in
336336 * the provided column index.
337337 *
338+ * @param region - The CellRegion to retrieve unique values for.
338339 * @param columnIndex - The index to retrieve unique values for.
339340 */
340341 async uniqueValues ( region : DataModel . CellRegion , columnIndex : number ) : Promise < any [ ] > {
@@ -348,6 +349,17 @@ export class ViewBasedJSONModel extends MutableDataModel {
348349 } ) ;
349350 }
350351
352+ /**
353+ * Returns a Promise that resolves to an array of unique values contained in
354+ * the provided column index after all transforms have been applied.
355+ *
356+ * @param region - The CellRegion to retrieve unique values for.
357+ * @param columnIndex - The index to retrieve unique values for.
358+ */
359+ async uniqueValuesVisible ( region : DataModel . CellRegion , columnIndex : number ) : Promise < any [ ] > {
360+ return this . _currentView . uniqueValues ( region , columnIndex ) ;
361+ }
362+
351363 get transformStateChanged ( ) : ISignal < this, TransformStateManager . IEvent > {
352364 return this . _transformSignal ;
353365 }
You can’t perform that action at this time.
0 commit comments