Radzen failing to get type of DataList

Hello Radzen Team!

I have two Models RulePeriod and RulePeriodTime, as follows:

[Table("rule_period")]
    public class RulePeriod {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int id { get; set; }
        public int ruleId { get; set; }
        public int type { get; set; }
        public DateTime start { get; set; }
        public DateTime finish { get; set; }
        public Rule rule { get; set; }
        public IEnumerable<RulePeriodTime> rulePeriodTimes { get; set; }
    }
[Table("rule_period_time")]
    public class RulePeriodTime {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int id { get; set; }
        public int rulePeriodId { get; set; }
        public int day { get; set; }
        public DateTime start { get; set; }
        public DateTime finish { get; set; }
        public RulePeriod rulePeriod { get; set; }
    }

Radzen, however, cannot automatically identify the 'rulePeriodTimes' type in the RulePeriod class:

I'm already forcing the TItem attribute:

The problem happens because the DataList type is treated as dynamic:

    protected RadzenDataList<Global.Models.RulePeriod> periodsDataList;
    protected RadzenDataList<dynamic> periodTimesDataList;

Resulting in the following error:

Cannot implicitly convert type 'Radzen.Blazor.RadzenDataList<Global.Models.RulePeriodTime>' to 'Radzen.Blazor.RadzenDataList<dynamic>'

You can try editing the JSON of that page and changing the itemType attribute of the DataList from dynamic to the desired value.

We will see if we can reproduce the problem from the provided code.

It's already set to the correct type in the .json:

"itemType": "Global.Models.RulePeriodTime",
"name": "periodTimesDataList",

Is this your project that uses models defined outside of Radzen? I think we already discussed that we don't support those cases. If not - we will need a sample project.

It was, now I'm running a pre-build script to copy all the models from the external reference into the Radzen project. All the problems I had before related to this issue were solved, since the models are now inside the project.

One thing that may be causing the issue is that I'm using nested templates, and each children are in a datalist with a template.

This is the Rule page and its RulePeriods datalist:

This is the RulePeriod template and its RulePeriodTimes datalist:

UPDATE:
Here's the Rule model:

[Table("rule")]
    public class Rule {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int id { get; set; }
        [MaxLength(100)]
        public string name { get; set; }
        public IEnumerable<RulePoint> rulePoints { get; set; }
        public IEnumerable<RulePeriod> rulePeriods { get; set; }
        public IEnumerable<PersonRule> personRules { get; set; }
        public IEnumerable<VehicleRule> vehicleRules { get; set; }
    }

We will investigate using the provided information and post here when there are some results.

The latest Radzen release should address this issue.

1 Like