Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Data-Bind nested JSON item to an ojListView

3241484Jun 1 2016 — edited Jun 3 2016

Hi all,

I am currently trying to bind some nested JSON to a list view item, I have successfully done this for one nested item shown below:

/<strong class="oj-flex-item" data-bind="foreach: resource.name"><span data-bind="text: family"></span></strong>/

JSON structure attached as screen shot for this,

How ever, when trying to bind the "code" for the value of "coding" using

/<strong class="oj-sm-flex-initial oj-flex-item oj-text-sm" data-bind="foreach: resource.practitionerRole"><span data-bind="foreach: role.coding"><span data-bind="text: code"</span></span></strong>/

JSON data also in screenshot.

I am getting an error, this is because some of the JSON objects do not have a value for role.coding.code, what can I do to handle list items that are fetched where this JSON data is not present and instead switch out the code value with a "Not specified" or such string? Would it be possible to use a KO if on the listview template to look at the value of resource.practitioner.role, and if no value is found - replaced the strong/span element above with a span to display the exception "not specified" message?

I have attached two images to show how the JSON response for the practitionerRole can vary from having an attribute for role and some not.Screen Shot 2016-06-01 at 16.36.29.png

Screen Shot 2016-06-01 at 16.37.13.png

Alternatively, Is there a cleaner way to bind these heavily nested object to the list items?

Note the data is dummy data provided by for public access.

With thanks,

Screen Shot 2016-06-01 at 15.44.17.pngScreen Shot 2016-06-01 at 15.45.20.png

This post has been answered by Jim.Marion-Oracle on Jun 2 2016
Jump to Answer
Comments
Post Details
Added on Jun 1 2016
5 comments
1,344 views