<input id="btn" />
<div id="Grid" data-bind="ejGrid: {
dataSource: flightsCollection,
allowPaging: false,
columns: [{ headerText: 'Date' }, { headerText: 'Name Details' }, { headerText: 'Price Details' }],
rowTemplate: '#templateOneWay',
actionBegin: gridHideShow,
}">
</div>
<script type="text/javascript">
$(function () {
window.kodata = [{ "OrderDate": new Date(8364186e5), "Name": "Nancy", "Price": 1000.00 },
{ "OrderDate": new Date(8264186e5), "Name": "Andrew", "Price": 1100.00 },
{ "OrderDate": new Date(8164186e5), "Name": "Janet", "Price": 1200.00 },
{ "OrderDate": new Date(8364186e5), "Name": "Margaret", "Price": 1300.00 },
{ "OrderDate": new Date(8564186e5), "Name": "Steven", "Price": 1400.00 },
{ "OrderDate": new Date(8664186e5), "Name": "Michael", "Price": 1500.00 },
{ "OrderDate": new Date(7364186e5), "Name": "Robert", "Price": 1600.00 },
{ "OrderDate": new Date(8364186e5), "Name": "Laura", "Price": 1700.00 },
{ "OrderDate": new Date(8364186e5), "Name": "Anne", "Price": 1800.00 }]
window.employeeView = {
flightsCollection: ko.observableArray(window.kodata),
gridHideShow: function (args) {
if (this.model.dataSource().length == 0 && (args.requestType == "refresh" || this.initialRender))
$("#Grid").hide();
else
$("#Grid").show();
}
};
ko.applyBindings(employeeView);
});
$('#btn').ejButton({
text: "Clear",
click: function (args) {
window.employeeView.flightsCollection([]);
}
});
|