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

Columns ForeignKey Aggregate problem

3 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rafał
Top achievements
Rank 1
Rafał asked on 28 Jun 2012, 09:32 AM
I have a some problem with Foreign Key column.
I use MVC 3 and Ajax DataBInding.
I would like to use Aggregate and ClientGroupHeaderTemplate and write count of rows, but didn't work.

this is my code
columns.ForeignKey(o => o.ID_Document_Status, (System.Collections.IEnumerable)ViewData["Statusy"], "ID", "Name_")
                .Width(50)
                .ClientTemplate("<strong><#= Status #></strong>")
                .Title("Status")
                .Aggregate(a => a.Count())
                .ClientGroupHeaderTemplate("<#= Count #>");.


please help

best regards
rafal

3 Answers, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 28 Jun 2012, 10:03 AM
Hi,

few tips:
1) If you have collection passed to the Grid like this @(Html.Telerik().Grid<SomeModel>(Model) ...)
 -remove the Model and let the Grid perform an Ajax request. Or you should define GroupHeaderTemplate
2) Make sure you have grouped the Grid by the ID_Document_Status column - otherwise the Grouping header for that particular column wont be displayed
0
Rafał
Top achievements
Rank 1
answered on 28 Jun 2012, 10:25 AM
This is my full code grid
       
@(Html.Telerik().Grid<LPI_Raportowanie.Models.ZPIModel>()
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.ID).Width(20).Visible(false);
            columns.Bound(o => o.NrRefZPI).Width(50).Title("Numer ZPI")
            columns.Bound(o => o.NameOfProjektIT).Width(300).Title("Nazwa projektu").Sortable(false);
            columns.ForeignKey(o => o.ID_Document_Status, (System.Collections.IEnumerable)ViewData["Statusy"], "ID", "Name_")
                .Width(50)
                .ClientTemplate("<strong><#= Status #></strong>")
                .Title("Status")
                .Aggregate(a => a.Count())
                .ClientGroupHeaderTemplate("<#= Count #>");
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Report"))
        .Sortable()
        .Scrollable(x => x.Height("500px"))
        .Filterable()
        .Groupable(settings => settings.Groups(groups => groups.Add(o => o.ID_Document_Status)).Visible(true))
 )
0
Rafał
Top achievements
Rank 1
answered on 29 Jun 2012, 12:22 PM
whether anyone know what is wrong ?
Tags
Grid
Asked by
Rafał
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Rafał
Top achievements
Rank 1
Share this question
or