Reputation: 169
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"}}, . . .]
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.
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"}, . . .]
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.
My for looking at the tables are here:
<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}}
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.
Upvotes: 1
Views: 1400
Reputation: 169
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}
instead of:
{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.
Upvotes: 1