@{
ViewData["Title"] = "Grid";
}
<ejs-button id="normalbtn" content="Render"></ejs-button>
<div>
<ejs-grid id="Grid" allowPaging="true">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" editType="numericedit" width="120"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType="dropdownedit"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
document.getElementById("normalbtn").addEventListener("click", function () {
var grid = document.getElementById('Grid').ej2_instances[0]; // Grid instance
var ajax = new ej.base.Ajax('/Home/DataSource', 'GET');
ajax.send();
ajax.onSuccess = function (data) {
grid.dataSource = JSON.parse(data);
};
})
</script> |
<ejs-button id="normalbtn" content="Render"></ejs-button>
<div>
<ejs-grid id="Grid" allowPaging="true">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" editType="numericedit" width="120"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType="dropdownedit"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
document.getElementById("normalbtn").addEventListener("click", function () {
var grid = document.getElementById('Grid').ej2_instances[0]; // Grid instance
grid.showSpinner();
var ajax = new ej.base.Ajax('/Home/DataSource', 'GET');
ajax.send();
ajax.onSuccess = function (data) {
grid.dataSource = JSON.parse(data);
grid.showSpinner();
};
})
</script>
|
...
<ejs-button id="normalbtn" content="Render"></ejs-button>
<div>
<ejs-grid id="Grid" allowPaging="true">
<e-grid-columns>
...
<e-grid-column field="OrderDate" headerText="Order Date" type="date" textAlign="Right" width="140"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType="dropdownedit"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
document.getElementById("normalbtn").addEventListener("click", function () {
var grid = document.getElementById('Grid').ej2_instances[0]; // Grid instance
grid.showSpinner();
var ajax = new ej.base.Ajax('/Home/DataSource', 'GET');
ajax.send();
ajax.onSuccess = function (data) {
grid.dataSource = JSON.parse(data);
grid.columns[3].format = { type: 'date', format: 'd.M.yyyy' }
grid.hideSpinner();
};
});
</script> |
...
<div id="container">
<ejs-grid id="Grid" allowPaging="true" dataBound="dataBound">
...
</ejs-grid>
</div>
<script>
var isSpinnerShown = false;
document.addEventListener("DOMContentLoaded", function () {
var grid = document.getElementById('Grid').ej2_instances[0]; // Grid instance
grid.hideSpinner = () => true;
var ajax = new ej.base.Ajax('/Home/DataSource', 'GET');
ajax.send();
ajax.onSuccess = function (data) {
grid.dataSource = JSON.parse(data);
grid.columns[3].format = { type: 'date', format: 'd.M.yyyy' };
isSpinnerShown = true;
};
});
function dataBound() {
if (isSpinnerShown) {
var spnElem = this.element.querySelector('.e-spinner-pane');
if (spnElem.classList.contains('e-spin-show')) {
spnElem.classList.remove('e-spin-show');
spnElem.classList.add('e-spin-hide');
isSpinnerShown = false;
}
}
}
</script> |