Our blazing fast Grid component built with pure JavaScript


Post by zettersten »

Hi,

I'm using the Grid with an AjaxStore. However, I don't have control or access to the underlying implementation of XHR. Meaning I cannot use Angular HttpClient built-ins such as HttpInterceptor for testing.

That said - is there a way to change or provide a custom XHR solution? I saw the AjaxHelper class, can that be swapped out?

Other reasons this is a good idea;

1. To inherit global http configuration options (session tokens, custom headers, timeouts, and retry logic)
2. To keep a single level of abstraction from XHR. To use HttpClient from angular and nothing else.
3. To be able to add middleware or logic to the pipeline of an http request.

Any advice would be very helpful.

Thank you,
Erik

Post by Maxim Gorkovsky »

Hello.
That sounds possible, you just need to override single enty-point of the AjaxHelper, which is fetch method:
import { Override, AjaxHelper } from 'bryntum-grid';

class AjaxHelperOverride {
  static get target() {
    return { class : AjaxHelper }
  }
  
  fetch(url, options) {
    return new Promise() // this should resolve with Response instance
  }
}

Override.apply(AjaxHelperOverride)

Post Reply