Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Whether Hierarchical Grid - Support GraphQL or now
posted

Hi Team,

Can you please check and let me know whether do we have feasibility to use GRAPHQL to bind data to hierarchical grid and emitted values can be transformed to GraphQL or not?

Please reach me on +91-7829446514 for any clarifications required on this.

Regards,

Rajendra

Parents Reply
  • 640
    Offline posted in reply to Rajendra Prasath Vijayavarman

    Hello Rajendra,

    Thank you for your patience while I was looking into this matter for you.

    I have created a sample, demonstrating how the Ignite UI for Angular Hierarchical Grid can work with GraphQL.

    By using the emitted FilteringExpressionsTree argument of the advancedFilteringExpressionsTreeChange event we can get all of the filtering expressions and build a GET query:

    public ngAfterViewInit() {
     ...
        this.hGrid.advancedFilteringExpressionsTreeChange.subscribe(e => {
          ...
          this.remoteService.getData(dataState, filteringOperands).subscribe(
            (data: any[]) => {
              this.hGrid.isLoading = false;
              this.hGrid.data = data;
              this.hGrid.cdr.detectChanges();
            },
            (error: any) => {
              this.hGrid.emptyGridMessage = error.message;
              this.hGrid.isLoading = false;
              this.hGrid.cdr.detectChanges();
            }
          );
        });
      }

    Then, all needed queries we can send to the server, where the filtering takes place:

    public buildQueries(filteringOperands: any[]): any {
            const result: IFilteringOperand[] = [];
            filteringOperands.forEach(operand => {
                const fieldName = operand.FieldName;
                const searchValueString = typeof operand.searchVal === 'string' ? operand.searchVal : '';
                const searchValueNumber = typeof operand.searchVal === 'number' ? operand.searchVal : null;
                const conditionName = operand.condition.name;
                result.push({ fieldName, searchValueString, searchValueNumber, conditionName });
            });
            return JSON.stringify(result);
        }

    The subscription for the advancedFilteringExpressionsTreeChange event of the child grids can be made when the gridCreated event is handled, which returns instances of the created child grid:

    public gridCreated(event: IGridCreatedEventArgs, _parentKey: string) {
      ...
        const grid = event.grid
        event.grid.advancedFilteringExpressionsTreeChange.subscribe(e => {
          ...
          this.remoteService.getData(dataState, filteringOperands).subscribe(
            (data: any[]) => {
              grid.isLoading = false;
              grid.data = data;
              grid.cdr.detectChanges();
            },
            (error: any) => {
              grid.emptyGridMessage = error.message;
              grid.isLoading = false;
              grid.cdr.detectChanges();
            }
          );
        });
      }

    Please keep in mind that I am using the Load on Demand feature for the initially loading of the child grids. More about this feature you can find here.

    Please test the sample on your side and let me know whether you find it helpful.

    Looking forward to hearing from you.

    Regads,
    Viktor Kombov
    Entry Level Software Developer
    Infragistics, Inc.

Children