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

[Solved] Grid Client Templates scope (this keyword) wrong

0 Answers 75 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.
Sam Critchley
Top achievements
Rank 1
Sam Critchley asked on 31 Jan 2011, 04:33 AM
I've got a client template in a grid and have been following the helps instruction for creating a client template. I wrote this simple one:

columns.Bound(o => o.CompliancePlanId).Title("Compliance Plan").ClientTemplate("<#= CompliancePlanId #>");
This doesn't work. I get nothing displayed. Upon further investigation I can see that the this keyword inside the template is resolving to the window object. So my template may as well be <#= window.CompliancePlanId #> which is completely useless. I must have some bugged out build, seems amazing that such a critical and obvious feature doesn't work.

I actually have a dropdown list in the edit template for this column called CompliancePlanId so what actaully render is: [object HTMLSelectElement] 

(That was after I gave up getting this telerik dropdown list to work in the grid. That just throws script errors out like candy.)

I'm using 210.2.825.235.

The whole grid:

<%= Html.Telerik().Grid<InspectorCompliancePlanViewModel>()
            .Name("Compliance")
            .ToolBar(p=>p.Insert())
.DataKeys(p=>p.Add(x=>x.Id))
            .Columns(columns =>
                {
                    columns.Bound(o => o.Id).Hidden(true);
                    columns.Bound(o => o.CompliancePlan).Hidden(true);
                    columns.Bound(o => o.CompliancePlanId).Title("CP ID").ReadOnly(true).Width(120);
                    columns.Bound(o => o.CompliancePlanId).Title("Compliance Plan").ClientTemplate("<#= CompliancePlanId #>");
                    columns.Command(p => p.Edit());
                })
            .DataBinding(db =>
                {
                    db.Ajax().Select("ListGridInspectorCompliancePlan""Inspector", hh.CreateUniqueRouteObject());
                    db.Ajax().Delete("RemoveInspectorCompliancePlan""Inspector", hh.CreateUniqueRouteObject());
                    db.Ajax().Insert("InsertInspectorCompliancePlan""Inspector", hh.CreateUniqueRouteObject());
                    db.Ajax().Update("UpdateInspectorCompliancePlan""Inspector", hh.CreateUniqueRouteObject());
                }
            )
            //.ClientEvents(p=>p.OnSave("rowsaved"))
.Editable(p=>p.Enabled(true))
            .Pageable(p=>p.Enabled(false))
            .Selectable()
            .EnableCustomBinding(true)
            
    %>
Tags
Grid
Asked by
Sam Critchley
Top achievements
Rank 1
Share this question
or