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

[Solved] Grid doesn't show any results if you have a template column after grouping

1 Answer 36 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.
Jason
Top achievements
Rank 1
Jason asked on 12 Oct 2010, 12:42 AM
Hello.  We have a grid that allows grouping, paging, sorting, and filtering that works fine, but if we add a template column, all of these functions stop working.  It appears they work, but no data is displayed.  Here is the configuration we have.

 

 

 

<% Html.Telerik().Grid(Model)
    .Name("SkuValidationSearchResults")
    .Columns(columns =>
    {
        columns.Add(c => c.SKUNumber).Filterable(false).Sortable(false).Groupable(false)
            .Title("Validation")
            .Template(c =>
            {                        
                %>
                    <%= Html.ActionLink("View", "Edit", "SkuValidation", new { skuID = c.SKUNumber, vendorID = c.VendorID, ipQTY = c.InnerPack, mpQty = c.MasterPack }, null)%>
                <%
    })
            .ClientTemplate("<a href=" + Url.Action("Edit", new { skuID = "{0}", vendorID = "{1}", ipQty = "{2}", mpQty = "{3}" }) + "/<# SKUNumber #><# VendorID #><# InnerPack #><# MasterPack #>View</a>");
        columns.Bound(c => c.PONumber);
        columns.Bound(c => c.POStatusCode);
        columns.Bound(c => c.SKUNumber);
        columns.Bound(c => c.SKUValidationStatus);
        columns.Bound(c => c.Description);
        columns.Bound(c => c.FirstShipDate).Format("{0:MM/dd/yyyy}");
        columns.Bound(c => c.VendorName);
    })
    .Groupable(grouping => grouping.Groups(groups =>
    {
        groups.Add(c => c.SKUValidationStatus);
    }))
    .DataBinding(dataBinding => dataBinding.Ajax().Select("GroupingAjax", "Home"))
    .Scrollable(scroll => scroll.Height(500))
    .Sortable(sorting => sorting
        .OrderBy(sortOrder => sortOrder.Add(o => o.FirstShipDate).Ascending()))
    .Pageable(paging => paging.Style(GridPagerStyles.NextPreviousAndNumeric).PageSize(50))
    .Filterable()
    .Render();
%>


I have read that template columns do not yet support grouping, sorting, etc., but it shouldn't cause the entire grid to stop working.  If not, how can I add the needed column without breaking grouping, etc.?  Once I read that it wasn't supported, I added the ").Filterable(false).Sortable(false).Groupable(false)" logic to see if that fixed it, but no such luck.

Thanks,
Jason

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Oct 2010, 07:36 AM
Hello Jason,

The cause for the observed behavior is incorrect ClientTemplate declaration. As you may know, the correct syntax  when using binding inside client template is as this <#= FieldName #>, however your declaration is missing the equal sign.
Also please note that the server code inside the client template will be evaluated only once, when the page is initially rendered, therefore in order to achieve the desired functionality you should modify the template similar to the following:
 

.ClientTemplate("<a href=" + Url.Action("Edit", new { skuID = "<#= SKUNumber #>", vendorID = "<#= VendorID #>", ipQty = "<#= InnerPack #>", mpQty = "<#= MasterPack #>" }) + ">View</a>");


Greetings,
Rosen
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
Jason
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or