Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143840 | Apr 7,2019 06:50 PM UTC | Apr 9,2019 01:04 PM UTC | ASP.NET Core - EJ 2 | 3 |
![]() |
Tags: DataGrid |
[index.cshtml]
<div class="control-section">
<button id="showBtn" onclick="onShowColumns()">Show Columns</button>
<button id="hideBtn" onclick="onHideColumns()">Hide Columns</button>
<ejs-grid id="Grid" dataSource="ViewBag.PurchaseData" allowPaging="true" allowResizing="true" allowReordering="true" gridLines="Both">
<e-grid-columns>
<e-grid-column field="TotalPrice" headerText="Total Price" textAlign="Right" format="C2" width="120"></e-grid-column>
<e-grid-column field="Price" headerText="Price" format="C2" width="150"></e-grid-column>
<e-grid-column field="Tax" headerText="Tax" textAlign="Right" format="C2" width="120"></e-grid-column>
<e-grid-column field="Shipping" headerText="Shipping" width="200"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
<script>
function onShowColumns(e) {
var grid = document.getElementById("Grid").ej2_instances[0];
grid.showColumns(["Price", "Tax", "Shipping"]);
}
function onHideColumns(e) {
var grid = document.getElementById("Grid").ej2_instances[0];
grid.hideColumns(["Price", "Tax", "Shipping"]);
}
</script> |
[index.cshtml]
<ejs-grid id="Grid" dataSource="ViewBag.PurchaseData" allowPaging="true" allowResizing="true" allowReordering="true" gridLines="Both">
<e-grid-columns>
<e-grid-column field="TotalPrice" headerText="Total Price" textAlign="Right" format="C2" allowReordering="false" width="120"></e-grid-column>
<e-grid-column field="Price" headerText="Price" format="C2" allowReordering="false" width="150"></e-grid-column>
<e-grid-column field="Tax" headerText="Tax" textAlign="Right" format="C2" allowReordering="false" width="120"></e-grid-column>
<e-grid-column field="Shipping" headerText="Shipping" width="200" allowReordering="false"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" width="200"></e-grid-column>
<e-grid-column field="CustomerAddress" headerText="Customer Address" width="200"></e-grid-column>
<e-grid-column field="Paymode" headerText="Pay Mode" width="200"></e-grid-column>
</e-grid-columns>
</ejs-grid>
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.