使用ASN角智能表的复杂对象 [英] Using asn Angular Smart-Table with complex objects
问题描述
我有一个数据收集,看起来像这样:
I have a data collection that looks like this:
[{"disposition": {"dispositionId":1,"name":"smdnfgn","code":"jkkhkl;hklhlkjhlhkj","description":"DM_Description 1","sortIndex":1,"status":"DM_St 1"}},{"disposition":{"dispositionId":2,"name":"DM_Name 2","code":"DM_Code 2;lkfdg;l'ksadfg","description":"DM_Description 2","sortIndex":2,"status":"DM_St 2"}}, . . .]
正如你可以看到后端RESTful服务返回的JSON数组是一个复杂的对象处置的对象(dispositionId,名称。)每次。
As you can see the JSON array returned by the backend RESTful service are 'disposition objects with a complex object (dispositionId, name, . . .) for each.
当我通过这个集合到一个智能表,我得到什么,但头。
When I pass this collection to a Smart-Table, I get nothing but headers.
然而,当我运行一个方法来删除'处置',把它变成一个数组simplier,如:
However, when I run a method to remove the 'disposition' and turn it into an simplier array, such as:
[{"dispositionId":1,"name":"smdnfgn","code":"jkkhkl;hklhlkjhlhkj","description":"DM_Description 1","sortIndex":1,"status":"DM_St 1"},{"dispositionId":2,"name":"DM_Name 2","code":"DM_Code 2;lkfdg;l'ksadfg","description":"DM_Description 2","sortIndex":2,"status":"DM_St 2"}, . . .]
一切工作正常。有没有办法让智能表识别标准的JSON配置,而无需一旦它被检索到的数据进行编辑?我觉得我忽视的东西。
Everything works fine. Is there a way to get the SMart-Table to recognize the standard JSON configuration without having to edit the data once it's been retrieved? I feel like I am overlooking something.
我对看表的位置:
<div ng-controller="dispositionSmartCtrl">
<hr>
DispoElements
<smart-table class="table table-striped" table-title="DispoElements"
config="globalConfig" rows=dispoElements columns="columnCollectionDispo">
</smart-table>
{{dispoElements}}<br /><hr><br />
Disposition RowDispositions
<smart-table class="table table-striped" table-title="RowDispositions"
config="globalConfig" rows=rowDispositions columns="columnCollectionDispo">
</smart-table>
{{rowDispositions}}
唯一的区别是所用,一个是复杂的对象的类别,另一个是香草阵列。我试过{{}},也做'rowCollections.disposition,第一个导致页面完全失败,第二次给了我一个头只表。
The only difference is the Collections being used, one being the complex object, the other being a vanilla array. I've tried {{}} and also doing 'rowCollections.disposition, and the first causes the page to fail completely, the second gives me a headers only table.
推荐答案
我设法解决这一个自己。什么似乎是一个头部划伤更多的是咄!时刻。它似乎复杂对象的原因是被忽略是双重的。第一误差,以及主之一,是在定义的列,我没有包括的对象引用。比如我有:
I managed to solve this one for myself. What seemed to be a head-scratch was more of a 'Duh!' moment. The reason it seemed to complex object was being ignored was two-fold. First error, and the main one, was that in defining the columns, I failed to include the object reference. For example I had:
{label: 'Name', map: 'name', isEditable: true}
而不是:
{label: 'Name', map: '***disposition***.name', isEditable: true}
的配合误差,列被列不符合最高级别的对象,所以智能表刚刚出现空行。如果我没有定义的列在所有的,我会看到对象而不是空白,并可能在已快避让我。
The compounding error was that the column being listed didn't correspond to the highest level object, so the smart-table just showed blank rows. If I hadn't defined the columns at all, I would have seen to Object rather than blank and that might have clued me in quicker.
这篇关于使用ASN角智能表的复杂对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!