This is a migrated thread and some comments may be shown as answers.

Retrieving additional values in ClientGroupHeaderTemplate

1 Answer 306 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Iain
Top achievements
Rank 1
Iain asked on 25 Mar 2015, 10:20 AM
Hello,

I have a grid that I'm grouping by the Value of a KeyValuePair property in my Model. I'm able to access the GroupedBy value (using "#= value#") in the ClientGroupHeaderTemplate, but I also need access to the Key (represented in the code below as "#= key#". Is it possible to do this?

@(grid.Name(Model.GridId)
.HtmlAttributes(new { @class = "kendo-grid", data_get_url = Url.Action("GetStaticPermissions", "PermissionSetRecord", new { permissionSetId = Model.PermissionSetId }) }) 
.DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action(Model.ReadAction, "PermissionSetRecord", new { category = Model.Category, permissionSetId = Model.PermissionSetId }))
        .Group(groups => groups.Add(permission => permission.PermissionGroupInfo.Value)))
    .Columns(columns =>
    {
        columns.Bound(d => d.PermissionGroupInfo.Value)
            .Hidden(true)
            .ClientTemplate("")
            .ClientGroupHeaderTemplate(GetTemplateTitle().ToHtmlString());
        columns.Bound(d => d.DisplayName)
            .Title(Saturn.Resources.Admin.Security.Permission);
        columns.Template(@<text></text>)
            .Title(Saturn.Resources.Admin.Security.AllowQuestion)
            .Width(100)
            .ClientTemplate(Html.Partial("Permissions/_Toggle", Model).ToHtmlString());
    }))

@helper GetTemplateTitle()
{
    <span>
          #= value# 
         
         
// I want access to the key of my property here
          #= key#
    </span>    
}

Thanks.








1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 27 Mar 2015, 08:57 AM
Hello Iain,

I posted a reply in the other thread that you opened on the same subject, for reference I will paste the reply here:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The only item that I assume you are searching for is called "field". Try to use 

#= field # inside your template and see if it suits your needs.

I hope this helps.

Kind Regards,
Petur Subev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Iain
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or