2

My grid:

    @( Html.Telerik().Grid<eGate.BackOffice.Core.Model.UI.EgateMenuRevisionViewData>()
        .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ParentId)
            .Aggregate(a => a.Count()).ClientGroupHeaderTemplate(Html.ActionLink("Create a Revision for This Menu", "Edit", "Thing", new { menuid = "<#= Key #>" }, null).ToString());
        columns.Bound(c => c.ParentName);
        columns.Bound(c => c.ThingName);

    })

    .Groupable(grouping => grouping.Groups(groups => { 
        groups.Add(c => c.EgateMenu.EgateMenuId);
    }).Visible(false))

This works. But it gives me:

Create a revision for this menu
1          Parent 1     Thing 1.1
1          Parent 1     Thing 1.2
1          Parent 1     Thing 1.3
Create a revision for this menu
2          Parent 2     Thing 2.1
2          Parent 2     Thing 2.2
2          Parent 2     Thing 2.3

And while that works, I'd much rather something more intuitive like:

Create a thing for parent 1
Thing 1.1
Thing 1.2
Thing 1.3
Create a thing for parent 2
Thing 2.1
Thing 2.2
Thing 2.3

Problem 1: Create a thing for... needs to pass the ParentId to the actionlink but it needs to display the ParentName for the client yet only one exists in the aggregate at a time.

Problem 2: I want to group by the Id without displaying the Id column in the results. But setting the column to visible(false) supresses the clientgroupheadertemplate.

3 Answers 3

0

Adding Visible(false) to the column binding suppresses the whole column itself from even being rendered in the client html - hence the suppression of the ClientGroupHeaderTemplate.

I would either try adding ParentId as a data key - e.g.

.DataKeys(keys =>
{
     keys.Add(k => k.ParentId);
}

I think this would only help if you were using the built in grid (AJAX or Server) DataBinding though (for Insert at least). With an ActionLink however... I don't have much experience with using mvc html helpers in client templates - but if you said the orignal example worked with it, shouldn't something like this work as well?

columns.Bound(c => c.ParentId).ClientTemplate("")
        .Aggregate(a => a.Count()).ClientGroupHeaderTemplate(Html.ActionLink("Create a thing for \"<#= ParentName #>\"", "Edit", "Thing", new { menuid = "<#= Key #>" }, null).ToString());

I added a blank ClientTemplate, which I assume would work so that the ID is not displayed.

0

Have you tried hiding the unwanted columns?

@( Html.Telerik().Grid<eGate.BackOffice.Core.Model.UI.EgateMenuRevisionViewData>()
    .Name("Grid")
.Columns(columns =>
{
    columns.Bound(c => c.ParentId).Visible(false);
        .Aggregate(a => a.Count()).ClientGroupHeaderTemplate(Html.ActionLink("Create a Revision for This Menu", "Edit", "Thing", new { menuid = "<#= Key #>" }, null).ToString());
    columns.Bound(c => c.ParentName).Visible(false);
    columns.Bound(c => c.ThingName);

})
-1

According telerik : You can specify now Aggregate property with following values: Sum, Min, Max, Last, First, Count, Avg & Custom for every GridBoundColumn and the grid will calculate these aggregates if ShowFooter is set to true. In case of Custom aggregate the grid will raise event OnCustomAggregate where you can set desired result using e.Result.

So try First, Last or Custom options for every GridBoundColumn and set ShowFooter property to false.

<telerik:GridBoundColumn Aggregate="First" DataField="CustomerID" DataType="System.String" 
  HeaderText="CustomerID" SortExpression="CustomerID" UniqueName="CustomerID"> 
</telerik:GridBoundColumn> 
1
  • -1 because this is Telerik ASP.NET MVC related question, not Telerik ASP.NET Ajax
    – Levitikon
    Mar 8, 2012 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.