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

[Solved] Grid Template Ajax

0 Answers 135 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.
Thomas
Top achievements
Rank 1
Thomas asked on 29 Jul 2011, 05:33 PM
So I ran into an issue where I have a Grid as a partial view loading inside a TabStrip.  When it fist loads everything looks as it should but soon as a request is made via Ajax any template column would disappear.  After much searching, I couldn't find a resolution for this.  The solution probably makes sense to most but can be one of those "Why didn't I think of that sooner." issues.  The key is to use both the columns.Template (for server side) and the columns.ClientTemplate (for client side a must for Ajax calls).

@(Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Visible(false);
            columns.Bound(o => o.Id)
                .Template(@<text>View Details @item.Id</text>)
                .ClientTemplate("View Details <#= Id #>' />")
                .Title("")
                .Width("50px");
            columns.Bound(o => o.CreatedWhen).Format("{0:MM/dd/yyyy HH:mm}").Width(150).Title("Created When");
            columns.Bound(o => o.TransactionType).Title("Transaction Type").Width("100px");
            columns.Bound(o => o.PaymentActionType).Title("Action").Width("50px");
            columns.Bound(o => o.PayStatusType).Title("Status").Width("100px");           
            columns.Bound(o => o.TransactionId).Title("Transaction Id").Width("100px");
            columns.Bound(o => o.Amount).Title("Amount").Width("100px");
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Server().Select("Payments", "Account", new { ajax = ViewData["ajax"] });
            dataBinding.Ajax().Select("_Payments", "Account").Enabled((bool)ViewData["ajax"]);
        })
        .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
        .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
        .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
        .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
        .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
        .Footer((bool)ViewData["showFooter"])
)
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Share this question
or