Ticket T1285227
Visible to All Users

DevExpress for Blazor - Grid Master-Detail with Entity Instant Feedback Source

created 6 days ago (modified 6 days ago)

Hello,

I am trying to figure out how to use Blazor Grid Master-Detail nested grid within a grid whose data is populated by an Entity Instant Feedback Source. I can't get it working, due to the following failure:

Call Stack
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100] Unhandled exception rendering component: Unable to cast object of type 'DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread' to type 'MasterDetail.Models.Customer'. System.InvalidCastException: Unable to cast object of type 'DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread' to type 'MasterDetail.Models.Customer'. at MasterDetail.Pages.WithInstantFeedbackSource.<>cDisplayClass00.<BuildRenderTree>b3(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at DevExpress.Blazor.Internal.GridDetailRow.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'IDce9jsv7DaqTGUKZWZrTLQSqHOLHHivIzAggiyu4'. System.InvalidCastException: Unable to cast object of type 'DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread' to type 'MasterDetail.Models.Customer'. at MasterDetail.Pages.WithInstantFeedbackSource.<>cDisplayClass00.<BuildRenderTree>b3(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at DevExpress.Blazor.Internal.GridDetailRow.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

I can't find any documentation that suggests EntityInstantFeedbackSource cannot be used with DetailRowTemplate (I do not see it itemized under the Blazor Grid server modes limitations documentation), but due to other limitations I am worried that is the case. I forked the demo example and made the following changes:

  1. The master-detail rows now display Orders instead of Invoices as the relationship between Customer and Order matches closer to my implementation than Customer and Invoice
  2. The Index.razor implementation does NOT use Instant Feedback Source, but was updated to reference/hydrate orders instead of Invoice lookup
  3. The new WithInstantFeedbackSource.razor (/with-instant-feedback-source) page mimics the Index.razor page exactly, except uses the EntityInstantFeedbackSource object to display data instead of the in-memory cached MasterGridData enumerable

Can you take a look and let me know if this is possible, and if it is possible how we would refactor WithInstantFeedbackSource.razor to do this?

Thank you!

Answers approved by DevExpress Support

created 5 days ago

Hello,

Thank you for the sample project.

Please refer to the following note in our documentation: Instant Feedback Source Specifics. I see that you use the DataItem property to pass Customer and Orders parameters. Note: if the AreSourceRowsThreadSafe property is set to false, you cannot access data source objects.

To resolve the issue, you can set the data source AreSourceRowsThreadSafe property to "true". Or, you can use the GetDataItemValue method to access data item properties.

Razor
<DetailRowTemplate Context="ctx"> @{ var orders = ctx.Grid.GetDataItemValue(ctx.DataItem, "Orders") as IEnumerable<Order>; } <WithInstantFeedbackSource_Grid_MasterDetail Phone="@ctx.Grid.GetDataItemValue(ctx.DataItem, "Phone").ToString()" Orders="@orders" /> </DetailRowTemplate>

Let me know if you have further questions.

    Comments (2)

      That is what I was missing! Thank you for the clarification. This is working well now.

      Tim (DevExpress Support) 4 days ago

        Hi,

        You're welcome. Should you have further questions, feel free to ask them.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.