<script type="text/template" id="template">
<div class="e-card">
<div class="e-card-title">${FirstName}</div>
<div class="e-card-header">
<div class="e-card-header-caption">
<div class="e-card-header-title">${Country}</div>
<div class="e-card-sub-title">${Title}</div>
</div>
</div>
<div class="e-card-content"> ${Notes}</div>
</div>
</script>
<script type="text/javascript">
function Myclick() {
const SERVICE_URI ='https://js.syncfusion.com/ejServices/Wcf/Northwind.svc/Employees';
// your database service using the EJ2 datamanager
new ej.data.DataManager({ url: SERVICE_URI, adaptor: new ej.data.ODataAdaptor })
.executeQuery(new ej.data.Query()).then((e) => {
var result = e.result;
var TemplateFn = ej.base.compile(document.getElementById('template').innerHTML.trim());
// bind that result data to each cards
result.forEach(function (data, index) {
card = TemplateFn(data);
cardEle = document.getElementById('card_sample_' + (++index));
if (cardEle) {
cardEle.appendChild(card[0]);
}
});
});
}
</script> |