goodGhost
goodGhost

Reputation: 3

SlickGrid Universal 5.2.0, 'preProcess' and 'process' does not work as expected on init process

I created a BackendService for Salesforce with SlickGrid Universal 5.2.0. And I was insert the console.log into the every functions to confirm execution order.

Here is BackendService.js I tested. I didn't add any business logic into BackendService, only console.log added. So I just want to confirm execution order.

export class BackendService {

    options = { ... }

    init(serviceOptions, pagination, grid, sharedService){

        ...

        console.log('backend service init finished');

    }

    updateFilters(columnFilters, isUpdateedByPresetOrDynamically){

        console.log('backend service updateFilters method');

    }

    updateSoters with just console.log like updateFilters;

    updatePagination with just console.log like updateFilters;

    updateOptions with just console.log like updateFilters;

    buildQuery(){

        console.log('backend service buildQuery');
        return 'SELECT Id, NAME FROM Account';

    }

    postProcess(respone){

       console.log('backend service internalPostProcess ', response);

    }

    processOnFilterChanged(..){
       console.log('backend service onFilterChanged');
       return this.buildQuery();
    }
    processOnSorterChanged(..){
       console.log('backend service onSorterChanged');
       return this.buildQuery();
    }
    processOnPaganationChanged(..){
       console.log('backend service onPaganationChanged');
       return this.buildQuery();
    }

}

And, here is gridOptions

gridOptions = {

    ...,

    presets : {

        ...

    },

    backendServiceApi : {

        service : new BackendService();

        options : { ... },

        preProcess: () => {

            console.log('backend servie preProcess');

        },

        process: (query) => {

            console.log('backend service process ', query);
            return [];

        }

        postProcess: (response) => {

            console.log('backend service postProcess ', response);

        }

    }
};

console.log('grid initialization start');
this.grid = new GridBundle(el, columns, gridOptions, []);
console.log('grid intialized -> ', this.grid)

It is run as following orders at initialization of grid.

  1. 'grid initialization start' log displayed.
  2. service.init()
  3. service.options.preset(filters, sorters, pagiantion)
  4. service.buildQuery()
  5. service.process() - with result of buildQuery()
  6. At this time, 'grid intialized -> grid object' log is displayed.
  7. service.preProcess()
  8. service.PreProcess() again
  9. service.processOn***Changed event
  10. service.process() - with null
  11. service.internalPostProcess()
  12. service.postProcess()

Excution order of the function 'bindBackendCallbackFunctions()' in the source code 'slick-vanilla-grid-bundle.ts' is correct I think. preset > buildQuery > preProcess > process.

However, real excution order is different as below. preset > buildQuery > process > preProcess, how can I solve this?

I believe correct execution orders are:

For onInit exection order : init > preset > buildQuery > preProcess > process > internalPostProcess > postProcess

For event excution order : preProcess > eventHandler > buildQuery > process > internalPostProcess > postProcess

Upvotes: 0

Views: 17

Answers (0)

Related Questions