Add additional parameters in second grouping request

Hello,

is there a possibility to add additional parameters to second grouping request?

I am using groupSettings.disablePageWiseAggregates property as true to get count for all data instead of only one page. With first request I am getting data for my page (before first request gridActionBegin method fires with requestType = grouping). After getting data and before sending other request for count I want to add more parameters (based on 'where' parameter in second request) to this request but in this place I am unable to find which (if there are any) method triggers to do this.

3 Replies

AG Ajith Govarthan Syncfusion Team March 5, 2020 02:58 PM UTC

Hi AC, 

Query: is there a possibility to add additional parameters to second grouping request? 

By default you can find the grouping count by using the group columns length from the groupSettings. So in the actionBegin event you can check if the group columns length is 2 and if so you can send additional parameters in the query and after action complete. In actionBegin event itself the current group column is added so you can get the group column length as 2 while grouping second column. 

Code Snippet: 
App.component.ts 

actionBegin(args: any){ 
if( this.grid.groupSettings.columns.length === 2){ 
                                         // your code here. 

Documentation links: 

Regards, 
Ajith G. 



UN Unknown Syncfusion Team March 9, 2020 07:34 AM UTC

Hello,

I think you misunderstand my question. I want to add additional parameters not when I am grouping second column, but in grouping second request (second request is to get counts for grouped columns when I am using disablePageWiseAggregates property set to true https://ej2.syncfusion.com/documentation/api/grid/groupSettings/#disablepagewiseaggregates). When this property is true - automatically two request are sent to WebAPI - first one to get data for page and second to get data for adding count to group columns by my all data instead of only count of one page data. I want to add additional parameters in this case in second request but not when I am grouping second time like you sent in your example.


AG Ajith Govarthan Syncfusion Team March 13, 2020 06:44 PM UTC

Hi AC , 

Sorry for the delayed response. 
  
Query: is there a possibility to add additional parameters to second grouping request? 
 
By default disable page wise aggregates will send additional request to calculate aggregate value for the for the aggregate columns. Currently we don’t have any events to send additional params So you can use our custom adaptor to send the additional params. We have created a sample with custom adaptor using that you can send the additional params in the processQuery method of the custom adaptor. 

App.component.ts 

  processQuery(dm: DataManager, query: Query, hierarchyFilters?: Object[]) { 
let queries: Requests = this.getQueryRequest(query); 
        let singles: QueryList = Query.filterQueryLists(query.queries, ['onSelect', 'onPage', 'onSkip', 'onTake', 'onRange']); 
        let params: ParamOption[] = query.params; 
        let url: string = dm.dataSource.url; 
        let temp: QueryOptions; 
        let skip: number; 
        let take: number = null; 
       ………. 
        ……. 

if (this.options.requestType === 'json') { 
            return { 
                data: JSON.stringify(req), 
                url: url, 
                pvtData: p, 
                type: 'POST', 
                contentType: 'application/json; charset=utf-8' 
            }; 
       
        temp = this.convertToQueryString(req, query, dm) as QueryOptions; 
        temp = (dm.dataSource.url.indexOf('?') !== -1 ? '&' : '/') + temp as QueryOptions; 
        // Here you can modify the request url as per your requirement 
        return { 
            type: 'GET', url: (<string>temp).length ? url.replace(/\/*$/, <string>temp) : url, pvtData: p 
        }; 
   




Please get back to us if you need further assistance. 

Regards,  
Ajith G. 


Loader.
Up arrow icon