I just ran into a situation with the Beta where setting the default value of a Guid column throws an error. Here is some pseudocode:
And the following Grid code (unnecessary parts omitted):
...where Model.Id is also a Guid, I get this error:
Exception Details: System.NotSupportedException: Cannot serialize objects of type System.Guid
Source Error:
Source File: d:\TFSWorking\AdvancedREI\Development\Development\src\AdvancedREI.Web\Views\Properties\_Edit.cshtml Line: 256
Stack Trace:
I can switch the Model to a string, set the default to Model.Id.ToString(), and then get it back into a Guid on the backend, but that is obviously not ideal.
Any chance this could get fixed before RTM?
Thanks!
public
class
FloorPlanModel
{
[ScaffoldColumn(
false
)]
public
Guid Id {
get
;
set
; }
[ScaffoldColumn(
false
)]
public
Guid PropertyId {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
decimal
Bedrooms {
get
;
set
; }
}
And the following Grid code (unnecessary parts omitted):
@(Html.Kendo().Grid<
FloorPlanModel
>()
.Name("floorPlanGrid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Bound(p => p.Bedrooms).Width(80).EditorTemplateName("Bedrooms");
})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model => {
model.Id(p => p.Id);
model.Field(p => p.PropertyId).DefaultValue(Model.Id);
model.Field(p => p.Bedrooms).DefaultValue(1);
})
)
)
Cannot serialize objects of type System.Guid
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NotSupportedException: Cannot serialize objects of type System.Guid
Source Error:
|
Source File: d:\TFSWorking\AdvancedREI\Development\Development\src\AdvancedREI.Web\Views\Properties\_Edit.cshtml Line: 256
Stack Trace:
|
I can switch the Model to a string, set the default to Model.Id.ToString(), and then get it back into a Guid on the backend, but that is obviously not ideal.
Any chance this could get fixed before RTM?
Thanks!