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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display other field in a group header

Thread ID:





146937 Aug 26,2019 12:23 PM UTC Aug 27,2019 11:01 AM UTC ASP.NET MVC - EJ 2 2
Tags: Grid
Asked On August 26, 2019 12:32 PM UTC

I'm looking for something like this: https://www.syncfusion.com/forums/135787/how-to-use-the-column-templatequotmytemplatequot-value-in-a-group-header
but in EJ2, MVC5.

My Grid:
       .GroupSettings(group => { group.ShowDropArea(false).Columns(new string[] { "InvestId" }).CaptionTemplate("#captiontemplate"); })

My template:

Caption fucntion

function caption(args) {
        console.log(args); // nothing here

Can you help?

Replied On August 26, 2019 12:33 PM UTC

//can't add my template code to the question, so I reply to add this

My template:
<script id="captiontemplate" type="text/x-template">
     <span class="badge badge-md badge-success" title="" style="font-size: unset">#${key} - ${caption()}</span>

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On August 27, 2019 11:01 AM UTC

Hi Customer,  
In the template, method can be called using the data as parameter as follows. The parameter will provide details about the current grouping column only which is the required behavior. If you would like to mention any other column, refer to the window.format method as shown in the code example.  
   . ..  
        . . .  
AllowGrouping().GroupSettings(group => { group.Columns(new string[] { "Freight" }).CaptionTemplate("#captiontemplate"); }).Render() 
<script id="captiontemplate" type="text/x-template"> 
    window.format = function (data) { 
        var inst = document.getElementById('Grid').ej2_instances[0] 
        var val = inst.getColumnByIndex(inst.getColumnIndexByField(data.field) + 1).field + ' - ' + data.key; 
        return val; 
Seeni Sakthi Kumar S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon