Hi,
I have a grid that lists my products. The columns are ProductCode, Description, Price and QtyToOrder.
The QtyToOrder column is rendered with a default value of zero.
I need the following:
<div class="container-fluid">
<h4 class="h4">Select Products to Order</h4>
<div id="dataGrid">
@Html.EJS().Grid("products").DataSource((IEnumerable<object>)ViewBag.products).Width("auto").Height("auto").Columns(col=>
{
col.HeaderText("Picture").Template("#template").Add();
col.Field("ProductCode").HeaderText("Product Code").IsPrimaryKey(true).Add();
col.Field("Description").HeaderText("Description").Add();
col.Field("Price").HeaderText("Unit Price").Add();
col.Field("QtyToOrder").HeaderText("Qty To Order").Add();
}).Height("700px").EditSettings(edit => { edit.AllowEditing(true).AllowAdding(false).AllowDeleting(false).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Render()
</div>
</div>
<style>
.image img {
height: 55px;
width: 55px;
border-radius: 10px;
box-shadow: inset 0 0 1px #e0e0e0, inset 0 0 14px rgba(0, 0, 0, 0.2);
}
</style>
<script id="template" type="text/x-template">
<div class="image">
<img src="/Content/Images/${ProductCode}.jpg" alt="${ProductCode}" />
</div>
</script>
I have added .AllowEditing(false) for all columns except the ProductCode and QtyToOrder columns. This takes care of the first requirement.
Now I still need the following:
From documentation, I was able to get only the rows where the QtyToOrder was not 0. I used the gridobject.
getBatchChanges().changedRecords to grab only where a qty was filled in. This then sends only those rows to the controller and from vontroller I can now do what I need to with teh grid data.