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

[Solved] Grid in a PartialView loaded by ajax

1 Answer 106 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.
Matt
Top achievements
Rank 1
Matt asked on 09 Jan 2011, 06:34 PM
The grid is in a partial view loaded in a tabstrip using LoadContentFrom. The tabstrip itself is in a partial view too. I understand that Template and ClientTemplate must be defined on each column because the grid is loaded by ajax using DataBinding. 

My code:
 
    <% Html.Telerik().Grid(Model)
        .Name("TheGrid")
        .Columns(columns =>
        {
            columns.Bound(c => c.Id)
            .Template(c =>
                     {
                       %>
                           <%= Html.ActionLink("Edit", "Edit", "Home", new { id = c.Id }, new object { })%>
                       <%
                     })
            .ClientTemplate("<a href='~/Home/Edit/<# Id #>'>Edit</a>")
            .Title("Edit");
            columns.Bound(c => c.Id)
            .Template(c =>
                     {
                       %>
                           <%= Html.ActionLink("Details", "Show", "Home", new { id = c.Id }, new object { })%>
                       <%
                     })
            .ClientTemplate("<a href='~/Home/Show/<# Id #>'>Details</a>")
            .Title("Details");
            columns.Bound(c => c.Id)
            .Template(c =>
                     {
                       %>
                       <% Html.BeginForm("AjaxDelete", "Home", new { id = c.Id }); %>
                           <%= Html.AntiForgeryToken()%>
                            <input type="submit" value="Delete" class="DeleteAction" />
                       <% Html.EndForm(); %>
                       <%
                     })
            .ClientTemplate("<button id='deletebtn<# Id #>' rel='<# Id #>' onclick='delete(this, <# Id #>)'>Delete</button>")
            .Title("Delete");
             
 
            columns.Bound(p => p.Name);
            columns.Bound(p => p.Created);
             
        })
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Home"))
        .Pageable()
        .Sortable()
        .Render();
%>

The grid loads fine however when I view subsequent pages the rows are empty. Without ClientTemplate I get an internal server error. Without the ClientTemplate I get nothing in the respective cells but the rest of the grid renders fine. When using Template, the html defined in the Template property is used. ClientTemplate seems to be ignored although it is needed.

Going back to the GridAndTabStrip example, I've updated it to the latest version and implemented something analagous to my main project to replicate the problem. See the ~/Home/Create.

1) It fails with internal server error if I use DataBinding on the grid (in GridLoadOnDemand) instead of Ajax. 
2) Paging on the grid fails to correctly load grid content if the column.Template property is not defined.
3) Internal server error if ClientTemplate only is defined which I believe is a known issue.

Any thoughts on how I can get this working please?

Thanks
Matt


1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Jan 2011, 08:37 AM
Hello Matt,

 We have uploaded a code library entry showing how to load a grid inside a tabstrip. You can check it here.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or