I have a SfGrid (19.3.0.57) in my page that populates successfully, but when I go to double-click on an item, it gives me an empty item.
When I observe the item in the GridActionBegin event, the event argument has a populated PreviousData object containing the object data, but the Data property is null.
My code:
<div class="row">
<div class="col-3">
<sfdropdownlist @ref="lst" titem="string" tvalue="string" placeholder="Select Location" datasource="service.LocationHandles">
<dropdownlistevents tvalue="string" titem="string" onvalueselect="LocationSelected">
<dropdownlistfieldsettings text="string" value="string">
</dropdownlistfieldsettings></dropdownlistevents></sfdropdownlist>
</div>
</div>
<div class="row">
<sfgrid @ref="grid" width="100%" datasource="@gridProducts" toolbar="@toolbar" allowselection="true" allowpaging="true">
<grideditsettings newrowposition="NewRowPosition.Bottom" mode="EditMode.Dialog" allowadding="true" allowediting="true" alloweditondblclick="true" showdeleteconfirmdialog="true" allowdeleting="true"></grideditsettings>
<gridevents tvalue="ProductGridModel" onactionbegin="GridActionBegin" onrecorddoubleclick="GridDoubleClick">
<gridcolumns>
<gridcolumn field="@nameof(ProductGridModel.RowKey)" isprimarykey="true" visible="false" allowediting="false"></gridcolumn>
<gridcolumn field="@nameof(ProductGridModel.Id)" type="ColumnType.Number">
<gridcolumn field="@nameof(ProductGridModel.Name)" headertext="Name">
<gridcolumn field="@nameof(ProductGridModel.Description)" headertext="Description">
<gridcolumn field="@nameof(ProductGridModel.Price)" headertext="Price">
<gridcolumn field="@nameof(ProductGridModel.Duration)" headertext="Duration(minutes)">
<gridcolumn field="@nameof(ProductGridModel.LocationId)" isprimarykey="true" visible="false" allowediting="false">
</gridcolumn></gridcolumn></gridcolumn></gridcolumn></gridcolumn></gridcolumn></gridcolumns>
</gridevents></sfgrid>
</div>
@code{
readonly List<string> toolbar = new() {"Add", "Edit", "Delete" };
SfDropDownList<string, string> lst;
SfGrid<ProductGridModel> grid;
public List<ProductGridModel> gridProducts { get; set; }
private void LocationSelected(SelectEventArgs<string> obj)
{
log.LogInformation(@"value selected: {Loc}",obj.ItemData);
log.LogTrace(@"ProductService has {ProdCount} products",service.Products.Count);
gridProducts.Clear();
gridProducts = service.Products.Where(x => x.LocationId == obj.ItemData).ToList();
log.LogInformation(@"grid is now bound to {PCount} products from {Loc}",gridProducts.Count,obj.ItemData);
grid.Refresh();
}
private void GridActionBegin(ActionEventArgs<productgridmodel> args)
{
if (args.RequestType == Action.BeginEdit)
{
if (args.Data == null)
{
log.LogTrace("grid item is null");
return;
}
log.LogTrace(@"{LocationId},{ProdID}",args.Data.LocationId,args.Data.RowKey);
}
}
I rolled back to the previous version and the issue was resolved.