Dear Support team,
Hope you are well and safe in this difficult time around the world. :)
The issue I'm having is about input component binding to data Context. For the code below:
<EjsDateTimePicker .... @bind-Value="rec.ReceivedDate" ....
If I'm using one-way binding (Value="@rec.ReceivedDate"), I can get data mapped and displayed within dialog with no issue. (But it turns out, I wouldn't get any data - ReceivedDate from the Dialog neither. Which is quite different to EjsTextBox behaviour. ) Furthermore, if I'm using two way binding, code shown above, then the "Save" button in the dialog will not do anything, e.g. not triggering action OnActionBegin
Where have I done wrong here please?
Sample codes shown below:
<div class="container p-0 m-0">
<div class="row">
<div class="col">
<EjsGrid TValue="Collection" AllowPaging="true" AllowSorting="true" AllowResizing="true"
EnableHover="true" GridLines="GridLine.Both" @ref="CollectionGrid" DataSource="@collectionList"
Toolbar="@(new List<string>() { "Add", "Edit", "Search"})">
<GridPageSettings PageSize="10"></GridPageSettings>
<GridEvents OnActionBegin="ModelActionBeginHander" TValue="Collection"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="false" Mode="@EditMode.Dialog">
<Template>
@{
var rec = (context as Collection);
<div class="col-md-12">
<br />
<div class="form-row">
<div class="form-group col">
<EjsTextBox ID="DisplayName" Value="@rec.DisplayName" FloatLabelType="@FloatLabelType.Auto" Placeholder="Collection name"></EjsTextBox>
</div>
</div>
<div class="form-row">
<div class="form-group col-6">
<EjsNumericTextBox ID="DeviceCount"Value="@rec.DeviceCount" FloatLabelType="@FloatLabelType.Auto" Placeholder="Device count"></EjsNumericTextBox>
</div>
<div class="form-group col-6">
<EjsDateTimePicker ID="ReceivedDatetime" TValue="DateTime?" @bind-Value="rec.ReceivedDate" FloatLabelType="@FloatLabelType.Auto" Placeholder="Received Datetime"></EjsDateTimePicker>
</div>
</div>
</div>
}
</Template>
</GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Collection.CollectionID) IsPrimaryKey="true" Visible="false"></GridColumn>
<GridColumn Field=@nameof(Collection.AccountManagerID) HeaderText="Account Manager" MinWidth="120" MaxWidth="280" Visible="false"></GridColumn>
<GridColumn Field=@nameof(Collection.DisplayName) HeaderText="Collection Name"></GridColumn>
<GridColumn Field=@nameof(Collection.ReceivedDate) HeaderText="Received Date" MinWidth="120" MaxWidth="280"></GridColumn>
<GridColumn Field=@nameof(Collection.DeviceCount) HeaderText="Device Count" MinWidth="120" MaxWidth="280"></GridColumn>
<GridColumn Field=@nameof(Collection.VatType) HeaderText="VAT Type" MinWidth="120" MaxWidth="280"></GridColumn>
<GridColumn Field=@nameof(Collection.Comments) HeaderText="Comments" MinWidth="120" MaxWidth="280" Visible="false"></GridColumn>
<GridColumn Field=@nameof(Collection.SupplierID) HeaderText="Supplier Company" MinWidth="120" MaxWidth="280" Visible="false" Type="@ColumnType.String"></GridColumn>
</GridColumns>
</EjsGrid>
</div>
</div>
</div>
///////////// code /////////////
public async Task ModelActionBeginHander(ActionEventArgs<Collection> args)
{
// Here you can customize your code
if (args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Save)
{
var rec = args.Data as Collection;
if (rec.CollectionID > 0)
await _db.UpdateCollection(rec);
else
{
rec.RefStatusID = await _db.GetStatusIDByCode("RECEIVED") ?? -1;
rec.ReceivedDate = (rec.ReceivedDate == null)? DateTime.UtcNow : rec.ReceivedDate;
await _db.AddCollection(rec);
var t = collectionList.FindIndex(c => c.CollectionID == 0 && c.DisplayName.Equals(rec.DisplayName));
if(t >= 0)
{
collectionList[t].ReceivedDate = rec.ReceivedDate;
}
}
args.Cancel = false;
StateHasChanged();
}
}