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

[Solved] Grid row count with Ajax binding

2 Answers 99 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.
Jane
Top achievements
Rank 1
Jane asked on 01 Jul 2012, 03:29 AM
Hello, 

how can I access grid row count with Ajax binding? 
I need to display total in a footer, see code snippet below.   The total has to update on insert and delete.   

With server binding, there is @Model.Count().  How can I do the same thing with Ajax binding?

thank you!
Jane

@{
        Html.Telerik()
            .Grid<ContractMonth>()
            .Name("contractMonthGrid")
            .DataBinding(dataBinding => dataBinding
                .Ajax()
                .Select("_AjaxBinding", "ContractMonth")
                .Insert("_AjaxInsert", "ContractMonth")
                .Update("_AjaxUpdate", "ContractMonth")
                .Delete("_AjaxDelete", "ContractMonth")
                )
            .DataKeys(keys => keys.Add(c => c.Id))
            .ToolBar(commands => commands.Insert())
            .Columns(columns =>
            {
                columns.Bound(o => o.StartDate).EditorTemplateName("Date").FooterTemplate(@<text>@Model.Count()</text>);

2 Answers, 1 is accepted

Sort by
0
Jane
Top achievements
Rank 1
answered on 02 Jul 2012, 07:41 PM
Excellent answer here: 
StackOverflow answer

.Columns(columns =>
    {
        columns.Bound(o => o.StartDate)
               .EditorTemplateName("Date")
               .Aggregate(aggregates => aggregates.Count())
               .FooterTemplate(@<text>@item.Count</text>)
               .ClientFooterTemplate("<#= Count #>");
    }
0
Le
Top achievements
Rank 1
answered on 04 Jul 2012, 09:56 AM
Thanks,
Tags
Grid
Asked by
Jane
Top achievements
Rank 1
Answers by
Jane
Top achievements
Rank 1
Le
Top achievements
Rank 1
Share this question
or