<div class="control-section">
<ejs-grid id="Grid" dataSource="@ViewBag.data" allowPaging="true" allowReordering="true" allowSelection="true" rowSelected="rowSelected">
<e-grid-selectionsettings type="Single"></e-grid-selectionsettings>
<e-grid-pagesettings pageSize="15"></e-grid-pagesettings>
<e-grid-selectionsettings mode="Row"></e-grid-selectionsettings>
<e-grid-columns>
<e-grid-column field="ID" headerText="ID" visible="false" textAlign="Right" width="120"></e-grid-column>
. . .
</e-grid-columns>
</ejs-grid>
</div>
<script>
function rowSelected(e) {
console.log(e.data.ID);
}
</script> |
[index.cshtml]
<a asp-page="./About" onclick="clickAction(this)">Edit</a>
<ejs-grid id="Grid" allowPaging="true" load="onLoad" rowSelected="onRowSelected" actionFailure="onActionFailure" toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})">
<e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" ></e-grid-editsettings>
<e-data-manager insertUrl="/Index?handler=Insert" removeUrl="/Index?handler=Delete" updateUrl="/Index?handler=Update" json="@Model.DataSource.ToArray()" adaptor="RemoteSaveAdaptor"></e-data-manager>
<e-grid-pageSettings pageCount="5" pageSize="5"></e-grid-pageSettings>
<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="CustomerName" headerText="CustomerName" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="City" headerText="City" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function clickAction(args) {
args.rel='nofollow' href = args.rel='nofollow' href + "/" + window.id.toString(); // Combine the OrderID with directed url
}
function onRowSelected(args) {
window.id = args.data["OrderID"]; // we have set a OrderID value in global variable(id) while grid selection
}
|