[英]Best way to show data from web service angular ui-grid
我正在從Web服務中獲取一個對象。 看起來像:
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看起來像:
[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; }
我認為ui-grid不是顯示對象內部具有許多數組的數據的最佳方法嗎?
無論使用哪種工具,使用多級數組作為數據源總是會造成混亂,但是UI-Grid可以做到。
您只需要綁定到正確的屬性路徑即可。 假設您有一個朋友數組,其中每個數組都以朋友的名字和姓氏為其元素。 如果要綁定第一個朋友的名字,則可以使用friends[0][0]
作為field
。 如下所示:
columnDefs = [
{ name: 'Name', field: 'name' },
{ name: '1st Friend 1st Name', field: 'friends[0][0]' },
];
data = [
{
"name": "Cox",
"friends": [
[
'Bob',
'Jones'
],
[
'Mary',
'Smith'
]
]
};
如果您想了解有關使用復雜綁定的更多信息,請閱讀以下文章: 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.