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

[Solved] Client template does not display.

1 Answer 94 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.
Jim
Top achievements
Rank 1
Jim asked on 19 Dec 2011, 04:49 PM
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();
 
%>

1 Answer, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 19 Dec 2011, 09:04 PM
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>";
            }
        }
    }

Tags
Grid
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Share this question
or