Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Client template does not display.

Not answered Client template does not display.

Feed from this thread
  • Jim avatar

    Posted on Dec 19, 2011 (permalink)

    There should be two columns with buttons but they do not show only the id does..   Can you see any issue with this grid?  it loads correctly just my  .ClientTemplate does not work.

    My ASCX and Grid

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<DirectInstall.Core.QueryDtos.ReportsLogDto>>" %>
     <script type="text/javascript">
        //<![CDATA[
         var idRowSelect = 0;
         var reportType = '';
         var reportsID = '';
         var ReportName = '';
         var project = '';
         var projectId = '';
         var innerVers = '';

         function loadReportHistoryControl(Id) {
             var reporturl = '<%= Url.Action("GetReportHistoryNext", "Reports")%>/';
             reportsID = Id;
             alert(reportsID);
             $.post(reporturl, { 'ReportId': Id }, function (data) {


                 $('#ReportHistoryGrid').html(data);



             });
             return false;
         }


         
        //]]>
        </script>

    <% Html.Telerik().Grid(Model)
            .Name("Grid")
            .DataKeys(keys => keys.Add(o => o.Id))
            .Columns(columns =>
            {

                //columns.Bound(m => m.ReportLogHistory.ReportName);
                columns.Bound(o => o.ReportType);
                columns.Bound(o => o.DateRun);
                columns.Bound(o => o.UserId);
                columns.Bound(o => o.Id)    
                 .ClientTemplate("<input type=\"button\" value=\"Download PDF\" onclick=\"loadReportHistoryControl('<#= Id #>', '');\" />")
                 .HtmlAttributes(new { style = "text-align:center" })
                 .Title("")
                 .Width(100);
                columns.Bound(o => o.Id)
                     .ClientTemplate("<input type=\"button\" value=\"Download Excel\" onclick=\"loadReportHistoryControl('<#= Id #>', '');\" />")
                      .HtmlAttributes(new { style = "text-align:center" })
                    .Title("")
                   .Width(100);

                columns.Bound(o => o.Id).Hidden(true);



            })
                .DataBinding(dataBinding => dataBinding
                        .Ajax()
                        .Select("GetReportHistoryNext", "Reports"))
                    .Scrollable(scrolling => scrolling.Height(200))
                    .Resizable(resizing => resizing.Columns(true))
                    .Reorderable(reorder => reorder.Columns(true))
                    .Sortable()
           //.Filterable()
                    .Pageable(paging => paging.PageSize(50))
                    .Selectable()
                        .Render();
     
    %>

    Reply

  • Jim avatar

    Posted on Dec 19, 2011 (permalink)

    Fixed it:  my new control:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<DirectInstall.Core.QueryDtos.ReportsLogDto>>" %>
     <%@ Import Namespace="DirectInstall.Core.QueryDtos" %>
     

    <% Html.Telerik().Grid(Model)
            .Name("Grid")
            .DataKeys(keys => keys.Add(o => o.Id))
            .Columns(columns =>
            {
                 columns.Template(o =>
                {
                   %><%= o.pdfButton%><%
    }).ClientTemplate("<#= pdfButton #>").Width(150).Title("<font color=black>PDF</font>");
                
                 columns.Template(o =>
                {
                   %><%= o.xlsButton%><%
                                          }).ClientTemplate("<#= xlsButton #>").Width(150).Title("<font color=black>XLS</font>");

                columns.Bound(o => o.DateRun);
                columns.Bound(o => o.UserId);
              

                columns.Bound(o => o.Id).Hidden(true);



            })
                //.DataBinding(dataBinding => dataBinding
                 //       .Ajax()
                 //       .Select("GetReportHistoryNext", "Reports"))
                    .Scrollable(scrolling => scrolling.Height(200))
                    .Resizable(resizing => resizing.Columns(true))
                    .Reorderable(reorder => reorder.Columns(true))
                    .Sortable()
           //.Filterable()
                    .Pageable(paging => paging.PageSize(50))
                    .Selectable()
                        .Render();
     
    %>

    Then I build the controls in the dto:
    [DisplayName("PDF")]
            public string pdfButton
            {
                get
                {
                    return "<a href='../ddd/dddd/" + this.Id + "'>Download</a>";
                }
            }
            [DisplayName("XLS")]
            public string xlsButton
            {
                get
                {
                    return "<a href='../dddd/dddd/" + this.Id + "'>Download</a>";
                }
            }
        }

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Client template does not display.
Related resources for "Client template does not display."

ASP.NET MVC Grid Features  |  Documentation  |  Demos  |  Telerik TV ]