Posted 15 October 2021, 2:49 am EST
Hi everyone.
I have some problems with OdataCollectionView
I have one wijmo grid component and powered by OdataCollectionView
My OdataCollectionView is like this :
public GetODataCollectionView(
url: string,
filterDefinition?: string,
expand?: string,
): ODataCollectionView {
this.getTokenFromLS();
return new ODataCollectionView(this.TOKEN_API, url, {
expand: expand,
filterDefinition: filterDefinition,
oDataVersion: 4,
pageOnServer: true,
pageSize: 10,
sortOnServer: true,
filterOnServer: true,
requestHeaders: {
Authorization: "Bearer " + this.bearerToken
},
});
}
I want to change the filter definition after created my component. But I can’t do this. If I enter the filter definition when creating component, OdataCollectionView filtering by the filter definition.
My list grid component is like this :
export class PurchaseInvoiceListComponent implements OnInit, OnDestroy {
dateFilterDefinition = "DocumentDate gt 2021-09-01T00:00:00.000Z and DocumentDate lt 2021-09-02T00:00:00.000Z";
colArr=[
...
]
changeFilter(){
// changed 2021-09-01 --> 2021-09-11 | 2021-09-02 --> 2021-09-22
this.dateFilterDefinition="DocumentDate gt 2021-09-11T00:00:00.000Z and DocumentDate lt 2021-09-22T00:00:00.000Z"
this.vtFlexGrid.refreshOdataCollection()
}
@ViewChild("vtFlexGridPurchaseInvoice", { static: true }) vtFlexGrid: VtFlexGridComponent;
constructor() {}
ngOnInit() {}
ngOnDestroy(): void {}
}
PurchaseInvoiceListComponent.html
<app-vt-flex-grid
#vtFlexGridPurchaseInvoice
oDataApiUrl="PurchaseInvoices"
filterDefinition={{dateFilterDefinition}}
gridID="PurchaseInvoicesGrid"
[columnArray]="colArr"
>
</app-vt-flex-grid>
<button (click)=changeFilter()> change filter </button>
My wijmo grid component is like this :
export class VtFlexGridComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() oDataApiUrl: string;
@Input() columnArray;
@Input() expand: string;
@Input() filterDefinition: string;
@Input() gridID: string;
public listData: ODataCollectionView; //
@ViewChild("flexGrid", { static: true }) grid: FlexGrid;
constructor() {}
ngOnInit() {
this.listData = this._httpService.GetODataCollectionView(
this.oDataApiUrl,
this.filterDefinition,
this.expand
);
}
refreshOdataCollection(){
this.listData = this._httpService.GetODataCollectionView(
this.oDataApiUrl,
this.filterDefinition,
this.expand
);
}
ngOnDestroy(): void {}
ngAfterViewInit(){}
}
When I changed filted definition and refreshed grid :
http://MyBackendUrl/PurchaseInvoices?$format=json&$count=true&$skip=0&$top=10