Telerik MVC Grid, can't display the count of objects.

Go To StackoverFlow.com

0

I have an entity named "AchFile", Ach Files have "batches associated with them. When the grid is populated from the action the count of batches displays. I have not been able to figure out how to get the count to display after the Ajax call which occurs when the grid is sorted. Instead of getting the count value for example "2" I get "[object Object],[object Object]" displayed in the column instead of 2.

       columns.Template(o => o.Batches.Count()).ClientTemplate("<span>"+"<#= Batches #>"+"</span>").Title("Batch Count");
2012-04-04 21:17
by dennisT
Here is what I finally got to work. It seems so easy now.

Add javascript to the top to the page to return the count of files.

<script>
function GetBatchCount(data) {
    var count = data.length;
    return count;
} </script>

Then change the ClientTemplate code to call the javascript.

                     columns.Template(o => o.Batches.Count()).ClientTemplate("<#= GetBatchCount(Batches) #>").Title("Batch Count");
< - dennisT 2012-04-04 22:03


0

You can directly call use <#= Batches.Count #>

2012-04-06 18:00
by Petur Subev
or the <#= Batches.length #> - Petur Subev 2012-04-06 18:01
Ads