简体   繁体   English

从Web服务角度ui-grid显示数据的最佳方法

[英]Best way to show data from web service angular ui-grid

I'm getting back an object from my web service. 我正在从Web服务中获取一个对象。 It looks like: 看起来像:

public DateTime CreationTime { get; set; } public bool Glossar { get; set; } public ICollection<BdConfigTablesTranslation> BdConfigTablesTranslations { get; set; } public ICollection<BdConfigTablesField> BdConfigTablesFields { get; set; } public ICollection<BdContent> BdContents { get; set; }

`ConfigTablesField looks like: ConfigTablesField看起来像:

[ForeignKey("BdConfigTableId")]
public BdConfigTable BdConfigTable { get; set; }
public int BdConfigTableId { get; set; }

[Required]
public bool FieldRequired { get; set; }

[Required]
public FieldType FieldType { get; set; }    
public ICollection<BdContentField> BdContentFields { get; set; }
public ICollection<BdConfigTablesFieldsTranslation> BdConfigTablesFieldsTranslation { get; set; }

I think ui-grid is not the best way to show data with a lot of arrays inside the object? 我认为ui-grid不是显示对象内部具有许多数组的数据的最佳方法吗?

Using multi-level arrays as your data source is always going to be confusing no matter what tool you use, but UI-Grid can do it fine. 无论使用哪种工具,使用多级数组作为数据源总是会造成混乱,但是UI-Grid可以做到。

You just need to bind to the right property path. 您只需要绑定到正确的属性路径即可。 Let's say you have an array of friends where each array has the friend's first and last name as its elements. 假设您有一个朋友数组,其中每个数组都以朋友的名字和姓氏为其元素。 If you wanted to bind to the first friend's first name, you would use friends[0][0] as the field . 如果要绑定第一个朋友的名字,则可以使用friends[0][0]作为field Here's what that would look like: 如下所示:

columnDefs = [
  { name: 'Name', field: 'name' },
  { name: '1st Friend 1st Name', field: 'friends[0][0]' },
];

data = [
  {
    "name": "Cox",
    "friends": [
      [
        'Bob',
        'Jones'
      ],
      [
        'Mary',
        'Smith'
      ]
    ]
};

If you want to learn more about using complex bindings you can read this post: http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ (caveat: I'm the author), and look at the docs here: http://ui-grid.info/docs/#/tutorial/106_binding . 如果您想了解有关使用复杂绑定的更多信息,请阅读以下文章: http : //brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ (注意:我是作者),然后在此处查看文档: http : //ui-grid.info/docs/#/tutorial/106_binding

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM