I cannot change new collectionview

Posted by: osmnkiraz11 on 15 October 2021, 2:49 am EST

    • Post Options:
    • Link

    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(){}
    
    }
    
    

    First query : http://MyBackendUrl/PurchaseInvoices?$format=json&$count=true&$skip=0&$top=10&$filter=DocumentDate%20gt%202021-09-01T00%3A00%3A00.000Z%20and%20DocumentDate%20lt%202021-09-02T00%3A00%3A00.000Z

    When I changed filted definition and refreshed grid :

    http://MyBackendUrl/PurchaseInvoices?$format=json&$count=true&$skip=0&$top=10

  • Posted 18 October 2021, 8:30 am EST

    Hi,

    We have replied to your query on the support case link below:

    https://www.grapecity.com/my-account/my-support/case/CAS-25969-S9S2M6

    Regards,

    Ashwin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels