We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to customize the grouping row data in React Grid

It is posible to customize the grouping row data?

I want to set the row text to something like --> TOTAL of group: xxxx



1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team January 29, 2020 09:15 AM UTC

Hi Oscar, 
 
Greetings from syncfusion support 
 
Query#: I want to set the row text to something like --> TOTAL of group: xxxx 
 
From analyzing your query we understand you want to customize the grouping row text in grid. You can customize the group caption by using the groupSettings.captionTemplate property.  
 
Please refer the below code example, sample and documentation for more information. 
 

export class Grouping extends SampleBase { 
    constructor() { 
        super(...arguments); 
        this.groupOptions = { showGroupedColumn: false, columns: ['Country'], 
        captionTemplate:'#groupTemplate' 
}; 
    } 
    dataBound() { 
        if (refresh) { 
            this.gridInstance.groupColumn('Country'); 
            refresh = false; 
        } 
    } 
    load() { 
        refresh = this.refreshing; 
    } 
    render() { 
        return (<div className='control-pane'> 
                <div className='control-section'> 
                    <GridComponent dataSource={inventoryData} allowPaging={true} ref={grid => this.gridInstance = grid} pageSettings={{ pageCount: 5 }} allowGrouping={true} groupSettings={this.groupOptions} allowSorting={true} height="320" dataBound={this.dataBound.bind(this)} load={this.load}> 
                        <ColumnsDirective> 
                             .  .  .  .  .  .  . 
                             .  .  .  .  .  .  . 
                        </ColumnsDirective> 
                        <Inject services={[Page, Group, Sort]}/> 
                    </GridComponent> 
                </div> 
            </div>); 
    } 
} 
 
Index.html 

<script id="groupTemplate" type="text/x-template"> 
            ${groupTemplate(data)} 
  </script> 
        <script type="text/javascript"> 

function groupTemplate(args) { 
    if (args.field == "Country") {            //we have customize the caption only for country field 
        return "TOTAL of group:" + args.count + " item"; 
    } 
} 
</script> 
 
 
 
Regards,
Prasanna Kumar N.S.V
 


Loader.
Up arrow icon