Hi,
I can use a ParentGrid Value in a Childgrid if I set the DefaultValue in the model to the TemplateField
.Model(model => {
model.Id(p => p.ALIASQLF);
model.Field(f=> f.ALIASQLF).DefaultValue("#=ALIASQLF#"); //is a field in the parentgrid and will be set at new row
})
But once I try to use a DateTime Value from the ParentGrid this approach does no longer work, as the Field expects a C# DateTime Value
Okay, just convert the Value to DateTime, right?
But the "#=FieldName#" Syntax does not seem to work as a parameter in a C# method
For Example, the following code will try to convert literally "#=ReplicationDateString#" instead of the datetime-string value:
.Model(model => {
model.Id(p => p.ReplicationDate);
model.Id(p=> p.VS_Jobnumber);
model.Field(f => f.ReplicationDate).DefaultValue(DateTime.ParseExact("#=ReplicationDateString#", "yyyy-MM-dd", CultureInfo.InvariantCulture));
})
Then just convert it within kendo, aight?
.Model(model => {
model.Id(p => p.ReplicationDate);
model.Id(p=> p.VS_Jobnumber);
model.Field(f => f.ReplicationDate).DefaultValue("#= kendo.parseDate("2022-02-02") #");
})
But the kendo.parseDate function always returns a string, so this did not work either, as it expects a C# DateTime.
Has anyone an Idea how to solve this problem? Is there a better approach?