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

[Solved] Checkbox client template not working when generated in code

1 Answer 116 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.
James
Top achievements
Rank 1
James asked on 10 Nov 2011, 05:36 PM
As outlined in this thread, I am dynamically generating my columns based on custom attributes as I need the grid to bind to dynamically typed objects.  Everything is going just fine, however I am trying to add a checkbox column, and ClientTemplate does not seem to be working.  Here is the code I have:

columnFactory.Bound(keyProperty.Name)
    .ClientTemplate(string.Format("<input name='checkedRecords' type='checkbox' value='<%= {0} %>' />", keyProperty.Name))
    .Title("")
    .Width(50)
    .HtmlAttributes(new { style = "text-align: center;" })
    .Sortable(false);

However, when my grid renders, I do not get a checkbox, instead I get the actual value of the property.
Now, maybe ClientTemplate isn't the right way to go?  I tried to get columnFactory.Template() to work, but to no avail.
Perhaps Kemal could chime in from the original thread?  Thanks.

1 Answer, 1 is accepted

Sort by
0
Martin MacPherson
Top achievements
Rank 1
answered on 22 Nov 2011, 11:32 PM
Hi,

I had a similar issue and found that the suggestion in this post solved it for me:

http://www.telerik.com/community/forums/aspnet-mvc/grid/client-template-not-displayed-with-mvc-grid.aspx#1177387

ie..

do <%= Html.Telerik().Grid<T>() instead of <%= Html.Telerik().Grid(Model)

Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Martin MacPherson
Top achievements
Rank 1
Share this question
or