【问题标题】:Blazorise DataGrid not Rendering ProperlyBlazorise DataGrid 无法正确呈现
【发布时间】:2021-04-21 15:58:01
【问题描述】:

我无法正确呈现 Blazorise 数据网格。我已经在要点中包含了这些位,json 被加载,但没有在网格中呈现。这是要点:

https://gist.github.com/bbqchickenrobot/9af26063108beb4acb75e9a9dc5b4ae0

【问题讨论】:

    标签: blazor blazor-client-side blazor-webassembly blazorise


    【解决方案1】:

    我测试了您的代码并完成了遗漏的代码,并且数据在 dataGrid 中正确显示。

    问题是您的 json 数据采用 camelCase 格式,而您在模型中使用了 PascalCase。 修改您的类模型,如下所示:

    using System;
    using System.ComponentModel.DataAnnotations;
    using System.Text.Json.Serialization;
    
    namespace Workflows.Blazo.Models
    {
        public class ApplicantViewModel
        {
            [Key]
             [JsonPropertyName("id")]
            public Guid Id { get; set; }
            [JsonPropertyName("firstname")]
            public string Firstname { get; set; }
              [JsonPropertyName("middlename")]
            public string Middlename { get; set; }
             [JsonPropertyName("lastname")]
            public string Lastname { get; set; }
            public DateTime? Dob { get; set; }
             [JsonPropertyName("emailAddress")]
            public string EmailAddress { get; set; }
            public string PhoneNumber { get; set; }
            public string EmployeeNumber { get; set; }
             [JsonPropertyName("offerDate")]
            public DateTime? OfferDate { get; set; }
             [JsonPropertyName("department")]
            public string department { get; set; }
             [JsonPropertyName("classificaiton")]
            public string Classificaiton { get; set; }
             [JsonPropertyName("createdDate")]
            public DateTime? CreatedDate { get; set; }
             [JsonPropertyName("modifiedDate")]
            public DateTime? ModifiedDate { get; set; }
    
          
        }
    }
    

    基于here 的考虑,我删除了ReadData="@OnReadData",否则您必须对数据进行所有加载、过滤和排序。

    这里是gridview的快照:

    【讨论】:

    • 很奇怪,这行得通。甚至没有考虑过 json 属性名称。我让它在没有这些的另一个项目中工作,但属性名称匹配。感谢您的提示!
    猜你喜欢
    • 2014-03-19
    • 2015-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    • 2015-09-27
    • 2015-10-21
    相关资源
    最近更新 更多