Skip to content

Commit f3d1e88

Browse files
committed
feat(igx-combo): expose virtualization props and event #1260
1 parent 4fefd97 commit f3d1e88

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

projects/igniteui-angular/src/lib/combo/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Basic usage of `igx-combo` bound to a local data source, defining `valueKey` and
1818
</igx-combo>
1919
```
2020

21-
Remote binding:
21+
Remote binding, defining `valueKey` and `displayKey`, and exposing `onDataPreLoad` that allows to load new chunk of remote data to the combo:
2222

2323
```html
24-
<igx-combo [data]="remoteData | async" [valueKey]="'ProductID'" [displayKey]="'ProductName'">
24+
<igx-combo [data]="remoteData | async" (onDataPreLoad)="dataLoading($event)" [valueKey]="'ProductID'" [displayKey]="'ProductName'" >
2525
</igx-combo>
2626
```
2727

@@ -188,6 +188,8 @@ When igxCombo is opened allow custom values are enabled and add item button is f
188188
| `valueKey` | combo value data source property | string |
189189
| `displayKey` | combo dispaly data source property | string |
190190
| `groupKey` | combo item group | string |
191+
| `virtualizationState` | defined he current state of the virtualized data. It contains `startIndex` and `chunkSize` | `IForOfState` |
192+
| `totalItemCount` | total count of the virtual data items, when using remote service | number |
191193
| `width ` | defines combo width | string |
192194
| `heigth` | defines combo height | string |
193195
| `itemsMaxHeight ` | defines drop down height | string |
@@ -206,6 +208,7 @@ When igxCombo is opened allow custom values are enabled and add item button is f
206208
| `onSelectionChange` | Emitted when item selection is changing, before the selection completes | true | { oldSelection: `Array<any>`, newSelection: `Array<any>`, event: Event } |
207209
| `onSearchInput` | Emitted when an the search input's input event is triggered | false | { searchValue: `string` } |
208210
| `onAddition` | Emitted when an item is being added to the data collection | false | { oldCollection: `Array<any>`, addedItem: `<any>`, newCollection: `Array<any>` }|
211+
| `onDataPreLoad` | Emitted when new chunk of data is loaded from the virtualization | false | { event: Event } |
209212
| `dropDownOpening` | Emitted before the dropdown is opened | false | { event: Event } |
210213
| `dropDownOpened` | Emitted after the dropdown is opened | false | { event: Event } |
211214
| `dropDownClosing` | Emitted before the dropdown is closed | false | { event: Event } |

projects/igniteui-angular/src/lib/combo/combo.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
[igxDropDownItemNavigation]="dropdown" [tabindex]="dropdown.collapsed ? -1 : 0" role="listbox" [attr.id]="dropdown.id">
4242
<ng-template igxFor let-item [igxForOf]="data | comboFiltering:filteringExpressions:filteringLogic | comboSorting:sortingExpressions | comboGrouping:groupKey"
4343
[igxForScrollOrientation]="'vertical'" [igxForContainerSize]="itemsMaxHeight"
44-
[igxForItemSize]="itemHeight" #virtualScrollContainer>
44+
[igxForItemSize]="itemHeight" (onChunkPreload)="dataLoading($event)" #virtualScrollContainer>
4545
<igx-combo-item [itemData]="item" isHeader={{item.isHeader}} role="option">
4646
<ng-container *ngIf="!item.isHeader">
4747
<igx-checkbox [checked]="isItemSelected(item)" disableRipple="true" disabled="true"></igx-checkbox>

projects/igniteui-angular/src/lib/combo/combo.component.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { cloneArray } from '../core/utils';
1111
import { IgxStringFilteringOperand, IgxBooleanFilteringOperand } from '../data-operations/filtering-condition';
1212
import { FilteringLogic } from '../data-operations/filtering-expression.interface';
1313
import { SortingDirection } from '../data-operations/sorting-expression.interface';
14-
import { IgxForOfModule } from '../directives/for-of/for_of.directive';
14+
import { IgxForOfModule, IForOfState } from '../directives/for-of/for_of.directive';
1515
import { IgxRippleModule } from '../directives/ripple/ripple.directive';
1616
import { IgxToggleModule } from '../directives/toggle/toggle.directive';
1717
import { IgxButtonModule } from '../directives/button/button.directive';
@@ -294,6 +294,16 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
294294
@Output()
295295
public onSearchInput = new EventEmitter();
296296

297+
/**
298+
* Emitted when new chunk of data is loaded from the virtualization
299+
*
300+
* ```html
301+
* <igx-combo (onDataPreLoad)='handleDataPreloadEvent()'></igx-combo>
302+
* ```
303+
*/
304+
@Output()
305+
public onDataPreLoad = new EventEmitter<any>();
306+
297307
/**
298308
* Sets the style width of the element
299309
*
@@ -549,6 +559,21 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
549559
this.dropdown.toggle();
550560
}
551561

562+
get virtualizationState(): IForOfState {
563+
return this.dropdown.verticalScrollContainer.state;
564+
}
565+
set virtualizationState(state) {
566+
this.dropdown.verticalScrollContainer.state = state;
567+
}
568+
569+
get totalItemCount() {
570+
return this.dropdown.verticalScrollContainer.totalItemCount;
571+
}
572+
set totalItemCount(count) {
573+
this.dropdown.verticalScrollContainer.totalItemCount = count;
574+
this.cdr.detectChanges();
575+
}
576+
552577
/**
553578
* @hidden
554579
*/
@@ -905,6 +930,13 @@ export class IgxComboComponent implements AfterViewInit, ControlValueAccessor, O
905930
this.filteredData = [...this.data];
906931
}
907932

933+
/**
934+
* @hidden
935+
*/
936+
public dataLoading(event) {
937+
this.onDataPreLoad.emit(event);
938+
}
939+
908940
/**
909941
* @hidden
910942
*/

0 commit comments

Comments
 (0)