Is it possible to re-use a client-template using asp.net ajax 4.0 client templates? I have a scenario as shown in the example below. I have two questions here:
- I could not get the if conditionwork in client-template
- How can I re-use the u l tag template for three types of "column" data (col1, col2, col3 in example json)?
sample code:
<style>
.sys-template { display:none; }
.list {width:220px; float:left; margin:0px 0px 0px 10px; background-color:#f2f2f2; }
</style>
<script src="MicrosoftAjax.debug.js" type="text/javascript"></script>
<script src="MicrosoftAjaxTemplates.debug.js" type="text/javascript"></script>
<script type="text/javascript">
var listItems = [{ item: "item1", col: "col1" },
{ item: "item2", col: "col1" },
{ item: "item3", col: "col1" },
{ item: "item4", col: "col2" },
{ item: "item5", col: "col2" },
{ item: "item6", col: "col2" },
{ item: "item7", col: "col2" },
{ item: "item8", col: "col3" },
{ item: "item9", col: "col3" },
{ item: "item10", col: "col3" }]
</script>
</head>
<body xmlns:sys="javascript:Sys" xmlns:dataview="javascript:Sys.UI.DataView" sys:activate="*">
<ul id="col1" class="list sys-template" sys:attach="dataview" dataview:data="{{ listItems }}">
<!--* if (col=="col1") { *-->
<li>{{item}}</li>
<!--* } *-->
</ul>
<ul id="col2" class="list sys-template" sys:attach="dataview" dataview:data="{{ listItems }}">
<!--* if (col=="col2") { *-->
<li>{{item}}</li>
<!--* } *-->
</ul>
<ul id="col3" class="list sys-template" sys:attach="dataview" dataview:data="{{ listItems }}">
<!--* if (col=="col3") { *-->
<li>{{item}}</li>
<!--* } *-->
</ul>
</body>