Hi Jeffrey,
Thanks for contacting Syncfusion support.
Query: “The context passed to Templates now seems to be of type TValue instead of the type passed in ModelType”
To replicate your issue at our end, we have prepared a sample with two different classes (one class for TValue and another one for ModelType) with the same properties to bind it to Grid. We can reproduce the reported issue while accessing the values in the template context.
Previously (till 17.2.0.47v) we will be serializing the string objects of template context by matching it with ModelType class. While using this approach we are not able to properly serialize the properties such as read-only, get-only properties, DateTimeOffset, TimeSpan, etc.
So from our latest Nuget release (17.2.0.50) we have modified this approach to bind those properties correctly by using the original object without serialization. Hence in the latest update, reported behavior occur. So here after it will not be possible to match the template context directly with ModelType. To overcome this behavior, we need to serialize manually from the context.
Refer the below code example
<GridColumn HeaderText="Employee Image" TextAlign="TextAlign.Center" Width="120">
<Template>
@{
var employee = JsonConvert.DeserializeObject<EmployeeData>(JsonConvert.SerializeObject(context)); // manually serialize the object to respective types.
<div class="image">
<button>@employee.FirstName</button>
</div>
}
</Template>
</GridColumn> |
For your convenience we have attached the sample with above solution. Kindly download the sample from below
Please find the release notes regarding this changes from below link
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan.