0

I am using angular js datatable for my project. Currently I am trying to access below object,

 "finalizedArr":[ 
 { 
 "treaceId":"KYC454353545", 
 "approval":[ 
 { 
 "usr":"kalindu kumara", 
 "threshold":100 
 }, 
 { 
 "usr":"kuma kalil", 
 "threshold":80 
 }, 
]}
]

I am using below code sample to generate table. This is the main part code

 $scope.dtColumns = [
 DTColumnBuilder.newColumn('traceId').withTitle('Trace ID'),
 DTColumnBuilder.newColumn('approval.usr').withTitle('Name'),
 DTColumnBuilder.newColumn('approval.threshold').withTitle('Match Strength %')
];

When I use this code, treaceId column is correctly rendered in the table. but 'usr' and 'threshold' not rendered. I think reason is ,usr and threshold inside the array. but i do not know how to modify this. Can you check my issue

Heretic Monkey
12.2k7 gold badges62 silver badges133 bronze badges
asked May 11, 2021 at 12:09

1 Answer 1

1

Out-of-the-box ngTable dynamic expects column.field to be property names, not navigators. (i.e. it doesn't handle dot syntax oneProperty.anotherProperty as it effectively does columnObject["fieldNameYouProvided"])

You could try a similar solution as noted here or you could try mapping your data model to a flat object.

Lastly, approval.usr and approval.threshold are not valid property accessors for the provided data model because approval is an array so to access the first values you would access them with approval[0].usr and approval[0].threshold which will not work as a dynamic column field property value for the aformentioned reasons.

answered May 18, 2021 at 18:16
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.