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

[Solved] Crash when using RowAction, Aggregates, & Razor

1 Answer 172 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.
iConect Developer - Mike
Top achievements
Rank 1
iConect Developer - Mike asked on 16 Dec 2011, 12:16 AM
If you take the example demo:

@model IEnumerable<Product>
 
@(Html.Telerik().Grid(Model)
      .Name("Grid")
      .Columns(columns =>
      {
        columns.Bound(o => o.ProductName)
                .Aggregate(aggregates => aggregates.Count())
                .FooterTemplate(@<text>Total Count: @item.Count</text>)
                .GroupFooterTemplate(@<text>Count: @item.Count</text>);
 
        columns.Bound(o => o.UnitPrice)
                .Width(200)
                .Aggregate(aggreages => aggreages.Sum())
                .Format("{0:c}")
                .FooterTemplate(@<text>Total Sum: @item.Sum.Format("{0:c}")</text>)
                .GroupFooterTemplate(@<text>Sum: @item.Sum.Format("{0:c}")</text>);
 
        columns.Bound(o => o.UnitsOnOrder)
                .Width(200)
                .Aggregate(aggregates => aggregates.Average())
                .FooterTemplate(@<text>Average: @item.Average</text>)
                .GroupFooterTemplate(@<text>Average: @item.Average</text>);
 
        columns.Bound(o => o.UnitsInStock)
                .Width(100)
                .Aggregate(aggregates => aggregates.Count().Min().Max())
                .FooterTemplate(
                @<text>
                    <div>Min: @item.Min</div>
                    <div>Max: @item.Max</div>
                </text>)
                .GroupHeaderTemplate(@<text>@item.Title: @item.Key (Count: @item.Count)</text>);
      })
        .Sortable()
        .Pageable()
        .Groupable(settings => settings.Groups(groups => groups.Add(o => o.UnitsInStock)).Visible(false))
)

And simply add in:

.RowAction(row =>
{
  if (row.DataItem.ProductName == "")
  {
    row.HtmlAttributes["style"] = "visibility:hidden";
  }
})

It crashes 100% of the time the following error:

Unable to cast object of type 'Telerik.Web.Mvc.Infrastructure.AggregateFunctionsGroup' to type 'Telerik.Web.Mvc.Examples.Models.Product'.

EDIT:

Upon further review it crashes in the ASPX version as well by adding this RowAction. Is this a known issue, and is there a work around?

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 16 Dec 2011, 10:28 AM
Hi Keith,

I was able to recreate the error you have described. We have addressed it and I'm attaching an internal build which contains the fix. I have also updated your telerik points as a token of gratitude for bringing this to our attention.

All the best,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
iConect Developer - Mike
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or