Hello,
I am trying to use/define templates based on meta-data. In the example below, I have hard coded a json array (to be replaced with remote data) that is used to populate the template, and other fields as well. While the correct templates are being invoked (identified by the for debug labels added), the date picker and drop list assigned to the data-role attribute are not functioning.
1. the mock data is bound to a list view, which
2. uses a template that calls a function
3. the function calls another template which contains the datepicker.
Thanks in advance for your help.
Regards,
Amit Kohli
<div id="container">
</div>
<script type="text/x-kendo-template" id="textBoxTemplate">
<input type="text" id="txt#=columnName#">
</script>
<script type="text/x-kendo-template" id="dateTemplate">
<input name="#=columnName#"
type="text"
data-type="date"
data-role="datepicker" /><label>for debug - date</label>
</script>
<script type="text/x-kendo-template" id="dropListTemplate">
<input name="dll#=columnName#" id="dll#=columnName#"
data-value-field="LookupValue"
data-text-field="LookupName"
data-source="#:lookupList#"
data-value-primitive="true"
data-role="dropdownlist" /><label>for debug - droplist</label>
</script>
<script type="text/x-kendo-template" id="outerTemplate">
<table>
<tr>
<td>#=columnDisplayName#</td>
<td>
#= renderEntityTemplate(data) #
</td>
</tr>
</table>
</script>
<script type="text/javascript">
//todo - amit k - validations for required, format, etc. ? May one assume all dates are required
$(document).ready(function () {
var mockData =
[
{ columnDisplayName: "Entity Code", columnName: "EntCode", templateType: "textBoxTemplate", lookupList: "" },
{ columnDisplayName: "Start Date", columnName: "EqEffBegDate", templateType: "dateTemplate", lookupList: "" },
{ columnDisplayName: "Entity Type", columnName: "EntTypeTID", templateType: "dropListTemplate",
lookupList: [{ "LookupValue": 1, "LookupName": "One" }, { "LookupValue": 2, "LookupName": "Two" }]
},
];
$("#container").kendoListView({
dataSource: mockData,
template: kendo.template($("#outerTemplate").html())
});
});
function renderEntityTemplate(data) {
//debugger;
return kendo.Template.compile($('#' + data.templateType).html())(data);
}
</script>
I am trying to use/define templates based on meta-data. In the example below, I have hard coded a json array (to be replaced with remote data) that is used to populate the template, and other fields as well. While the correct templates are being invoked (identified by the for debug labels added), the date picker and drop list assigned to the data-role attribute are not functioning.
1. the mock data is bound to a list view, which
2. uses a template that calls a function
3. the function calls another template which contains the datepicker.
Thanks in advance for your help.
Regards,
Amit Kohli
<div id="container">
</div>
<script type="text/x-kendo-template" id="textBoxTemplate">
<input type="text" id="txt#=columnName#">
</script>
<script type="text/x-kendo-template" id="dateTemplate">
<input name="#=columnName#"
type="text"
data-type="date"
data-role="datepicker" /><label>for debug - date</label>
</script>
<script type="text/x-kendo-template" id="dropListTemplate">
<input name="dll#=columnName#" id="dll#=columnName#"
data-value-field="LookupValue"
data-text-field="LookupName"
data-source="#:lookupList#"
data-value-primitive="true"
data-role="dropdownlist" /><label>for debug - droplist</label>
</script>
<script type="text/x-kendo-template" id="outerTemplate">
<table>
<tr>
<td>#=columnDisplayName#</td>
<td>
#= renderEntityTemplate(data) #
</td>
</tr>
</table>
</script>
<script type="text/javascript">
//todo - amit k - validations for required, format, etc. ? May one assume all dates are required
$(document).ready(function () {
var mockData =
[
{ columnDisplayName: "Entity Code", columnName: "EntCode", templateType: "textBoxTemplate", lookupList: "" },
{ columnDisplayName: "Start Date", columnName: "EqEffBegDate", templateType: "dateTemplate", lookupList: "" },
{ columnDisplayName: "Entity Type", columnName: "EntTypeTID", templateType: "dropListTemplate",
lookupList: [{ "LookupValue": 1, "LookupName": "One" }, { "LookupValue": 2, "LookupName": "Two" }]
},
];
$("#container").kendoListView({
dataSource: mockData,
template: kendo.template($("#outerTemplate").html())
});
});
function renderEntityTemplate(data) {
//debugger;
return kendo.Template.compile($('#' + data.templateType).html())(data);
}
</script>