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

Title() and ClientTemplate() not working when I bind dynamic columns

1 Answer 399 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sharon
Top achievements
Rank 1
sharon asked on 26 Nov 2015, 11:07 PM

Function Title(), ClientTemplate() and encode(false) don't work when I bind dynamic columns  in a hierarchy grid.

Some columns contains html like <br/>. I tried Encode(false), but it doesn't work.

 

 

View: 

    @(
 Html.Kendo().Grid<dynamic>().Name("Grid")
    .DataSource(ds => ds.Ajax()
                    .Model(m =>
                    {
                        foreach (System.Data.DataColumn column in Model.AssessmentData.Columns)
                        {
                            m.Field(column.ColumnName, column.DataType);

                        }
                    })
            .Read(r => r.Action("GetStudentResult", "StudentDetail",
                new { studentID = "#=StudentID#", headerID = "#=HeaderID#" }))
    )
    .Name("grid_#=HeaderID#")
    .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.AssessmentData.Columns)
        {
            var c = columns.Bound(column.ColumnName);
            c.Title(column.ColumnName + "_test");
            c.ClientTemplate("<div class='test'>#:" + column.ColumnName + "#</div>");

        }
    })
    .Sortable()
    .ToClientTemplate()

    )

 Controller:

         public ActionResult GetStudentResult([DataSourceRequest] DataSourceRequest request,
            int studentID, int headerID)
        {
            DataTable dt = this.core.GetAssessResult(studentID, headerID, 
                this._loginInfo.SchoolID);

            string test = JsonConvert.SerializeObject(dt.ToDataSourceResult(request));
            return Content(test, "application/json");

        }

 

 

 

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 30 Nov 2015, 02:17 PM

Hello sharon,

 

Please find attached a solution that shows how to implement the desired functionality - use ClientTemplates and Title methods with dynamic columns. 

 

Hope that this will be helpful. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
sharon
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or