<EjsGrid id="Grid" @ref="@grid" ModelType="@model" AllowPaging="true" DataSource="@data" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Dialog">
<Template>
@{
var employee = (context as Orders);
<table class="e-table e-inline-edit" cellspacing="0.25">
<colgroup>
<col style="width: 120px;">
<col style="width: 120px;">
</colgroup>
<tbody>
<tr>
<td style="text-align: right" class='e-rowcell'>
<input class="e-input e-field" name='Freight' value="@employee.Freight" required type="text" />
</td>
<td class='e-rowcell'>
<div class="e-input-group">
<input class="e-input e-field" name='CustomerID' value="@employee.CustomerID" required type="text" />
</div>
</td>
</tr>
</tbody>
</table>
}
</Template>
</GridEditSettings>
<GridColumns>
<GridColumn Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@Syncfusion.EJ2.Blazor.Grids.TextAlign.Right" Width="90"></GridColumn>
<GridColumn Field="CustomerID" HeaderText="Customer ID" Width="90"></GridColumn>
<GridColumn Field="EmployeeID" HeaderText="Employee ID" Width="90"></GridColumn>
<GridColumn Field="Freight" HeaderText="Freight" Width="90"></GridColumn>
</GridColumns>
</EjsGrid>
………………………….
List<Orders> data;
private EjsGrid grid;
public List<Orders> order = new List<Orders>();
public Orders model = new Orders();
……………………………
|
|
<environment include="Development">
<link rel="stylesheet" rel='nofollow' href="css/bootstrap/bootstrap.min.css" />
</environment> |
<EjsGrid id="Grid" @ref="@grid" ModelType="@model" AllowPaging="true" DataSource="@data" OnActionBegin="onBegin" OnActionComplete="onComplete" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
………………………………………………………………..
</EjsGrid>
…………………………………………
public void onBegin(object args)
{
If(args.requestType == “Add”)
{
//perform your action here while adding a record
}
If(args.requestType == “BeginEdit”)
{
//perform your action here while editing a record
}
}
|
<EjsGrid id="Grid" @ref="@grid" ModelType="@model" AllowPaging="true" DataSource="@data" OnActionBegin="onBegin" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Dialog">
<Template>
@{
var employee = (context as Orders);
@if (@employee.IsAdd.ToString() == "true") {
<table class="e-table e-inline-edit" cellspacing="0.25">
<colgroup>
<col style="width: 120px;">
<col style="width: 120px;">
</colgroup>
<tbody>
<tr>
…………………………………………………
</tr>
</tbody>
</table>
}
else
{
<table class="e-table e-inline-edit" cellspacing="0.25">
<colgroup>
<col style="width: 120px;">
<col style="width: 120px;">
</colgroup>
<tbody>
<tr>
…………………………………………………
</tr>
</tbody>
</table>
}
}
</Template>
</GridEditSettings>
<GridColumns>
………………………………………….
</GridColumns>
</EjsGrid>
………………………………………………………..
public void onBegin(ActionEventArgs args)
{
if(args.RequestType.ToString() == "Add")
{
var obj = JsonConvert.DeserializeObject<Orders>(JsonConvert.SerializeObject(args.RowData));
obj.IsAdd = true;
}
} |