jQWidgets Forums

jQuery UI Widgets Forums Angular Fetching data from within a jqxGrid handler

This topic contains 2 replies, has 2 voices, and was last updated by  jlu 5 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • jlu
    Participant

    Hi, I would like to dynamically fetch row details information from our backend server, but the HttpClient service that is initialized by my component is not available from the initrowdetails() handler – how can I do that?

    This is the demo I am following:

    angular-grid-rowdetails demo

    I would like to modify the initrowdetails:
    initrowdetails = (index: any, parentElement: any, gridElement: any, datarecord: any): void => {
    console.log(this.httpClient); // this.httpClient undefined!?

    this.httpClient.get(apiUrl, {})
    .toPromise().then(resp => {
    // update parentElement.innerHTML
    });
    }

    My main component has a constructor that initializes the httpClient service:
    constructor(private router: Router,
    private httpClient: HttpClient) {
    console.log(this.httpClient); // correctly prints the obj
    }

    My question is that if this.httpClient is undefined inside the jqx handler (“this” no longer refers to the main component), how can I get a hold of the main component object within the hander, or how can I fetch data from a url within a jqx handler?

    Thanks!

    Fetching data from within a jqxGrid handler #106853

    Hristo
    Participant

    Hello jlu,

    It sounds like this happens because the operations are asynchronously.
    You could get the data and when it is ready to update it to the RowDetails of the jqxGrid.
    For this purpose you could use the updatebounddata method and update it then.

    Also, I tested this example and it seems to work fine.
    Could you provide us with one simplified example that demonstrates your case?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    jlu
    Participant

    Thank you, fetch() is the function I was looking for, but it’s not published on the API documentation.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.