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

Grid with Templates

4 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 21 Dec 2011, 05:25 PM
I'm trying to create a grid with a column template that has a KendoDropDownList of Checkboxes. The checkboxes are checked on load based on the data source of the grid.

I have the following, but it doesn't work at all. Can someone point me in the right direction please?

Thank you.

<
table id="grid" height="300px">
    <thead>
        <tr>
            <th data-field="Content1">Content</th>
        </tr>
    </thead>
</table>
   
<script id="consumersTemplate" type="text/x-kendo-tmpl">
    <select id="dropdownlist" />
</script>

<script id="consumerTemplate" type="text/x-kendo-tmpl">
    <input type="checkbox" name="#= Name #" value="#= Name #" 
    # if (#= IsSelected#) { # 
        checked
    }
    /
</script> 

$("#grid").kendoGrid({
    dataSource
        ConsumersName"John"IsSelectedfalse }Name"Jane"IsSelectedtrue }
        ConsumersName"John"IsSelectedtrue }Name"Jane"IsSelectedfalse
    ],
   height200,
   scrollable{
     virtualtrue
   },
   columns[
       
           templatekendo.template($("#consumersTemplate")
                                    .kendoDropDownList(
                                        template$("#consumerTemplate").html(),
                                        dataSourcekendo.template("#=Consumers#")
           ).html())
       }
   ],
   selectabletrue
}); 

4 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 22 Dec 2011, 10:24 AM
Hi,

You can initialize the dropdown lists in the dataBound event of the grid. This example illustrates the approach. 

All the best,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ingolf
Top achievements
Rank 1
answered on 27 Dec 2011, 11:50 AM
Hi,

your example doesn't work on IE 8 or IE 7.

Any idea?

0
Petyo
Telerik team
answered on 27 Dec 2011, 12:32 PM
Hi,

Sorry for that. Seems like templates from script tags are choking in jsFiddle. Along with that, there was an extra comma present. Check this version.  


http://jsfiddle.net/FsEVT/

Regards,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Ingolf
Top achievements
Rank 1
answered on 27 Dec 2011, 03:41 PM
Hi,

thanks for your reply.

I have found the solution too. The Comma is the problem but .text() is also the problem. After changing in .html() the example works fine in IE 8.

Change
template$("#consumersTemplate").text()
to
template
$("#consumersTemplate").html()
       

regards Ingolf
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Ingolf
Top achievements
Rank 1
Share this question
or