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. (Last updated on: June 24, 2019).
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:

Created:

Updated:

Platform:

Replies:

146937 Aug 26,2019 12:23 PM UTC Aug 27,2019 11:01 AM UTC ASP.NET MVC - EJ 2 2
loading
Tags: Grid
Gin
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:
<div> 
    @(Html.EJS().Grid("Grid") 
        ... 
       .GroupSettings(group => { group.ShowDropArea(false).Columns(new string[] { "InvestId" }).CaptionTemplate("#captiontemplate"); })
        ... 
     ) 
div> 

My template:

Caption fucntion

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

Can you help?
Thank!

Gin
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>
</script>

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.  
 
 
 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource). 
   . ..  
        . . .  
AllowGrouping().GroupSettings(group => { group.Columns(new string[] { "Freight" }).CaptionTemplate("#captiontemplate"); }).Render() 
 
<script id="captiontemplate" type="text/x-template"> 
    ${format(data)} 
</script> 
 
<script> 
    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; 
    } 
</script> 
 
Regards,  
Seeni Sakthi Kumar S. 


CONFIRMATION

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