OData update failing to construct PATCH
Using current (26.1.40) Blazor controls, in Blazor Web App, OData (v4) grid updates have started failing. In existing app, they used to work OK, but have started to fail.
Traced cause to Grid update is generating HTTP Patch to OData controller, including ALL FIELDS, including associated entries, even if just one field (e.g. Notes was updated).
The included Grid looks like this:
<SfGrid ID="Grid" TValue="ScripTransaction" @ref="Grid" AllowPaging=false Height="100%" Width="100%" EnableVirtualization=true ShowColumnChooser=true AllowSelection=true AllowSorting=true AllowFiltering=true AllowGrouping=true AllowResizing=true [email protected] Query=Qry>
<SfDataManager @ref="dm" Url="odata/ScripTransactions" DataType="ScripTransaction" Adaptor="Adaptors.ODataV4Adaptor" Key="Id" />
<GridFilterSettings Type=@MyFilterType />
<GridPageSettings PageSize="100" />
<GridSortSettings>
<GridSortColumns>
<GridSortColumn Field="Traded" Direction="SortDirection.Descending" />
</GridSortColumns>
</GridSortSettings>
<GridGroupSettings ShowDropArea=false ShowGroupedColumn=true />
<GridTemplates>
<ToolbarTemplate>
<CToolBar @ref="MyToolBar" MyGrid=@Grid SelectedRowIndex=@SelectedRowNum [email protected] MyEditMode=@MyEditMode />
</ToolbarTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field="@nameof(st.Id)" HeaderText="Id" IsPrimaryKey=true IsIdentity=true Width="80" Visible=false />
<DateCol Field="@nameof(st.Traded)" HeaderText="Traded" />
<GridColumn Field="@nameof(st.TranType)" HeaderText="Tran Type" Width="70" />
<GridColumn Field="@nameof(st.Status)" Width="90">
<EditTemplate>
<CDropDownList ID="stStatus" TItem="ReferenceList" TValue="string" @bind-Value="@((context as ScripTransaction)!.Status)" DataSource="@StatusList" PopupWidth=200>
<DropDownListFieldSettings Value="Key" Text="Key" />
</CDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(st.Account)" HeaderText="Account" Width="100" Visible=false></GridColumn>
<GridColumn Field="@nameof(st.CustodyAccount)" HeaderText="Custody" Width="80" Visible=false></GridColumn>
<GridColumn Field="@nameof(st.CashAccount)" HeaderText="Cash Acct" Width="80" Visible=false></GridColumn>
<DateCol Field="@nameof(st.Settled)" HeaderText="Settled" />
<DateCol Field="@nameof(st.TaxDate)" HeaderText="Tax Date" Visible=false />
<GridColumn Field="@nameof(st.Instrument)" HeaderText="Inst Id" Width="80" EditorSettings="@NumEditParams" Visible=false />
<GridColumn Field="InstrumentE.Code" HeaderText="Inst" Width="80" AllowEditing=false>
<Template>
@{
ScripTransaction st = (context as ScripTransaction);
if (st?.InstrumentE != null) {
<a rel='nofollow' href="instrument/@st?.Instrument.ToString()" target="inst">@st?.InstrumentE.Code</a>
}
}
</Template>
</GridColumn>
<GridColumn Field="InstrumentE.Name" HeaderText="Name" Width="280"></GridColumn>
<GridColumn Field="@nameof(st.Broker)" Width="90">
<EditTemplate>
<CDropDownList ID="stBroker" TItem="Broker" TValue="string" @bind-Value="@((context as ScripTransaction)!.Broker)" DataSource="@Brokers" PopupWidth=200>
<DropDownListFieldSettings Value="Id" Text="Name" />
</CDropDownList>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(st.Notes)" HeaderText="Notes" />
<GridColumn Field="@nameof(st.Order)" HeaderText="Order" Width="90" />
<GridColumn Field="@nameof(st.ContractNote)" HeaderText="Con Note" />
...
If I ONLY UPDATE the [Notes] field, then attempt save: the following PATCH request body is generated:
{
"Id": 741788,
"LastModified": "2024-07-04T10:41:49.323+10:00",
"TranType": "Buy",
"Traded": "2024-03-08T00:00:00+11:00",
"Settled": "2024-03-13T00:00:00+11:00",
"InstrumentCode": null,
"ParentInstCode": null,
"TaxDate": "2024-03-08T00:00:00+11:00",
"Instrument": 10748,
"ParentInst": null,
"Account": "RE000001.2",
"CashAccount": "RE000001.3",
"CustodyAccount": null,
"Status": "Settled",
"DisplayToClient": null,
"Location": "Custody",
"Broker": "CMC",
"Custodian": null,
"Order": null,
"ContractNote": null,
"Quantity": 1175.000000,
"Price": 8.8100000000,
"Currency": "AUD",
"AcctExchRate": 1.00000000,
"CashExchRate": 1.00000000,
"BeneExchRate": 1.00000000,
"FeeAuto": null,
"Fee": 11.0000,
"FeeRule": 15,
"CostBaseOrig": 10362.7500,
"Batch": null,
"Source": null,
"ContraID": null,
"InstrumentEvent": null,
"Notes": "Mistake. Intended Sell Orderss",
"GlClientAuto": null,
"GlAdminAuto": null,
"MigrationSource": null,
"Created": "2024-03-12T14:19:48.9+11:00",
"CreatedBy": 31,
"LastModifiedBy": 42,
"ScripAllocation": null,
"FixedCostBase": false,
"Strategy": null,
"StrategyDate": null,
"Num": null,
"Value": 10351.7500,
"AcctValue": 10362.7500,
"CashAcctValue": 10362.7500,
"Allocations": [],
"Disposals": [],
"GlEntries": [],
"ScripTranTypeE": null,
"InstrumentE": {
"Id": 10748,
"LastModified": "2023-11-09T10:35:49.4+11:00",
"Name": "Data#3 Ltd. FPO",
"Market": "ASX",
"Exchange": null,
"Type": "fpo",
"SubType": "FPO",
"Status": "A",
"IsTradeable": false,
"Units": "Shares",
"Currency": "AUD",
"OrderByValue": false,
"PricingFrequency": "Daily",
"LiveQuoteAvail": false,
"PricingSource": 6,
"PricingSourceCode": "DTL",
"PricingSourceMultiple": 1.000000,
"EventSource": null,
"LastPriceUpdate": null,
"LastEvent": null,
"APIRCode": null,
"MinOrderValue": 0.0000,
"MinOrderUnits": 0.0000,
"OrderMultiples": 1.0000,
"AllowSpecieTransfers": false,
"MaturityDate": null,
"PenaltyPreMaturity": false,
"CGTType": "Capital",
"ParcelAllocLocation": "None",
"WHTaxCountry": "AUS",
"WHTSetting": null,
"Created": "2021-11-23T17:29:25.067+11:00",
"Company": "DATA#3 LIMITED",
"Code": "DTL",
"TradingCalendar": "ASX",
"Issued": 154704064,
"Listed": "1997-12-18T00:00:00+11:00",
"GICS": "4510000",
"DeListed": null,
"CreatedBy": 31,
"ISIN": "AU000000DTL4",
"SEDOL": "6093015",
"LastModifiedBy": 31,
"FrankedPct": 1.0000,
"FrankingRate": 0.3000,
"InstrumentTypeE": null,
"MarketE": null,
"InstStat": null,
"ScripTransactions": [],
"HistDailies": [],
"Transactions": [],
"EventLogs": [],
"Notes": [],
"Events": [],
"GlTransactions": [],
"Components": [],
"Versions": [],
"StrategyEvents": [],
"GICSCategoryE": null,
"Orders": [],
"InstHistStats": [],
"InstHistories": []
},
"OrderE": null,
"InstEvent": null
}
This request fails, as many of the unedited fields are not editable. Please advise.
Regards,
Phil
Hi Phil,
We have confirmed this an issue and logged the defect report “HTTP patch request not working properly in OData Controller,includes all fields even when only one field is edited” for the same and this fix will be included in our upcoming patch.
You can now
track the current status of your request, review the proposed resolution
timeline, and contact us for any further inquiries through this
link.
HTTP
patch request not working properly in OData Controller,includes all fields even
when only one field is ed in Blazor | Feedback Portal (syncfusion.com)
Disclaimer: “Inclusion of this solution in
the weekly release may change due to other factors including but not limited to
QA checks and works reprioritization”
We will get back to you once the release is rolled out. Until then we
appreciate your patience
Regards,
Prathap S
Thanks for your patience,
We are glad to announce that, we have included the fix for the reported “HTTP patch request not working properly in OData Controller, includes all fields even when only one field is edited” in our 26.2.4 release. So please upgrade to our latest version of Syncfusion NuGet package to resolve the reported issue. Please find the NuGet package for the latest fixes and features below.
NuGet: https://www.nuget.org/packages/Syncfusion.Blazor.Grid
Root Cause: We are
trying to dispose of an instance that has already been disposed of.
Action Taken:Handle the disposal only after ensuring that all instances
have been disposed of
We thank you for your support and appreciate your patience in waiting for this release.
Thanks Prathap,
I have tested the new release, and found the problem seems to be improved, but only 1/2 fixed. In the same example described in the original post,
1) If I update the ContractNote field in the bound SfGrid, a correct PATCH request is generated with the following body
{
"ContractNote": "test 3"
}
2) If I update the Notes field in the exact same scenario, an incorrect PATCH request is generated with the following body
{}
3) If I update the ContractNote and Notes fields in same schenario, an incorrect PATCH request is generated with the following body
{
"ContractNote": "test 34"
}
Without testing too many other fields to isolate (many fail), I cannot even see a difference between these two fields ContractNote and Notes, as they are both just sting? fields in entity model
[StringLength(50)]
public virtual string? ContractNote { get; set; }
[StringLength(200)]
public virtual string? Notes { get; set; }
and the Grid column definitions are same:
<GridColumn Field="@nameof(st.Notes)" HeaderText="Notes" />
<GridColumn Field="@nameof(st.ContractNote)" HeaderText="Con Note" />
Please advise.
Phil
Sorry for the inconvenience ,
We are unable to reproduce the reported issue when attempting to reproduce the issue in the latest version 26.2.4 . For your reference we have attached screen recording and simple sample .So, to further proceed with the reporting problem, we require some additional clarification from your end. Please share the below details to proceed further at our end.
- To analyze the reported issue, could you please share a simple and reproducible sample that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.
- Could you please share us the video demonstrating of the issue and replication steps?
- If possible, kindly share your attempt to replicate the issue using the attached simple sample.
Above-requested details will be very helpful in validating the reported query at our end and providing a solution as early as possible. Thanks for your understanding.
Attachment: sample_and_recording_edd161b4.zip
Updated reply on other issue-log
https://support.syncfusion.com/support/tickets/609110#update-6376332
Hi Phil,
Please follow up on that support ticket for further updates regarding your issue.
Regards,
Getsy
- 6 Replies
- 3 Participants
-
PH Phil Holmes
- Jul 4, 2024 03:25 AM UTC
- Jul 30, 2024 04:36 AM UTC