blazor-docs/knowledge-base/common-readonly-properties.md

1.9 KiB

title description type page_title slug position tags ticketid res_type
Editing does not Work When Model Properties are Read-Only or Without Setters The editing fails when the bound model has read-only properties troubleshooting Editing does not Work When Model Properties are Read-Only or Without Setters common-kb-read-only-properties grid, scheduler, edit, telerik, blazor, readonly, setter 1631052, 1620193, 1621413, 1632496, 1632497 kb

Environment

Product Grid for Blazor,
Scheduler for Blazor

Description

Editing does not work, and the OnUpdate event does not fire when a property in my bound model does not have a setter or is read-only.

Error Message

If the Telerik source code is attached to the app, the following exception is thrown:

System.ArgumentException: Property set method not found.

Cause

By design, the component clones the edited data item, so the user can cancel editing and restore the original value. When the Grid clones the item, the component creates a new model instance and tries to set its properties. However, when some properties are read-only, the component is unable to set their properties, and an exception is thrown.

Solution

Currently, the only solution is to bind the component to a view model with non-read-only properties with setters. If the reason for using read-only properties is to prevent editing in some columns, you can set Editable="false" to the column in question.

Notes

There is an open feature request that will allow developers to populate the cloned edit item manually, this will be an alternative solution to this scenario.