开发者

How to remove "column name: " from grouped column in Telerik MVC (razor) grid control

I am looking at using the Telerik MVC3 Razor grid control for a project.

Grouping works really well, but is it possible to remove the "column name: " from the grouping? e.g.

"Product Size: Large"
"Product Size: Small"
"Product Size: Medium"

change to

"Large"
"Small"
"Medium"

If I add a GroupHeaderTemplate to the Column(c=>c...) then I can get the text to say whatever I want...but then the same column is also displayed later on in my grid (after the grouping columns)

@(Html.Telerik().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.SheetLine).Visible(false)
            .Aggregate(a => a.Count())
            .GroupHeaderTemplate(@<text>@item.Key (@item.Count)</text>);
        columns.Bound(c => c.VSACode);
        columns.Bound(c => c.Bucket100)
            .Title("First");
    })
    .Groupable(groupable => groupable.Groups(group =>
                        {
                            group.Add(g => g.SheetLine);
                            group.Add(g => g.PrintLine);
                            group.Add(g => g.SelectionLine);
                        }).Visible(false))
)

displays

How to remove "column name: " from grouped column in Telerik MVC (razor) grid control

and

@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.SheetLine)
                .Aggregate(a => a.Count())
                .GroupHeaderTemplate(@<text>@item.Key</text>);
            columns.Bound(c => c.VSACode);
            columns.Bound(c => c.Bucket100)
                .Title("First");
        })
        .Groupable(groupable => groupable.Groups(group =>
                            {
                                group.Add(g => g.SheetLine);
                                group.Add(g => g.PrintLine);
                                group.Add(g => g.SelectionLine);
                            }).Visible(false))
    )

displays

How to remove "column name: " from grouped column in Telerik MVC (razor) grid control

But I can't find the middle ground to开发者_开发百科 get rid of that second "SheetLine" so it is only a grouped column AND has a groupheadertemplate.


You can simply apply the following technique:

   @(Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
           columns.Bound(c => c.SheetLine)
                .Aggregate(a => a.Count())
                .GroupHeaderTemplate(@<text>@item.Key (@item.Count)</text>).Hidden(true);

            columns.Bound(c => c.PrintLine)           
                .GroupHeaderTemplate(@<text>@item.Key</text>).Hidden(true);

            columns.Bound(c => c.SelectionLine)          
                .GroupHeaderTemplate(@<text>@item.Key</text>).Hidden(true);

            columns.Bound(c => c.VSACode);
            columns.Bound(c => c.Bucket100)
                .Title("First");
        })
        .Groupable(groupable => groupable.Groups(group =>
                            {
                                group.Add(g => g.SheetLine);
                                group.Add(g => g.PrintLine);
                                group.Add(g => g.SelectionLine);
                            }).Visible(false))
    )


Looks like the following issue which has been reported on the Telerik support forums here:

http://www.telerik.com/community/forums/aspnet-mvc/grid/custom-label-for-group.aspx

Currently there is no way to configure this, but you can make the column on which you group hidden (Hidden()). Just make sure that you place that column last in the list to support IE.

So basically you have to implement a solution that places the columns on which you group last in the list of defined columns for the grid and then you have to hide them (Hidden()...not Visible(false)!).


try this,On grid databound:

if($('#grid tbody .k-grouping-row:contains("FieldName") td p').length != 0)
{
  $('#grid tbody .k-grouping-row:contains("FieldName") td p')[0].innerHTML = "<[a]  tabindex=\"-1\" class=\"k-icon k-i-collapse\" href=\"#\" /> Your text";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜