Skip to Content
0

SAPUI5: Displaying JSON values in a table

Feb 10, 2017 at 03:39 PM

90

avatar image
Former Member

I have the following JSON where I need to display some properties in a table (for simplification just one "object" but the real JSON has more):

{
   "objects":[
      {
         "object":{
            "properties":{
               "cmis:objectId":{
                  "id":"objectId",
                  "localName":"objectId",
                  "displayName":"Object Id",
                  "queryName":"objectId",
                  "type":"id",
                  "cardinality":"single"
               },
               "cmis:path":{
                  "id":"cmis:path",
                  "localName":"path",
                  "displayName":"Path"
               },
               "cmis:allowedChildObjectTypeIds":{
                  "id":"cmis:allowedChildObjectTypeIds",
                  "localName":"allowedChildObjectTypeIds",
                  "displayName":"Allowed Child Object Types Ids",
                  "queryName":"cmis:allowedChildObjectTypeIds",
                  "type":"id",
                  "cardinality":"multi",
                  "value":null
               },
               "cmis:lastModifiedBy":{
                  "id":"cmis:lastModifiedBy",
                  "localName":"lastModifiedBy",
                  "displayName":"Last Modified By",
                  "queryName":"cmis:lastModifiedBy",
                  "type":"string",
                  "cardinality":"single",
                  "value":",hoffman"
               },
               "cmis:objectTypeId":{
                  "id":"cmis:objectTypeId",
                  "localName":"objectTypeId",
                  "displayName":"Object Type Id",
                  "queryName":"cmis:objectTypeId",
                  "type":"id",
                  "cardinality":"single",
                  "value":"cmis:folder"
               },
               "cmis:description":{
                  "id":"cmis:description",
                  "localName":"description",
                  "displayName":"Description",
                  "queryName":"cmis:description",
                  "type":"string",
                  "cardinality":"single",
                  "value":null
               }
            }
         }
      }
   ]
}

I'm not able to address the properties I want. At least something seems to be right because the table shows always the correct number of rows. But the rows are always empty. None of my experiments below in the <Text> fields are working:

<Label text="Number of objects: {myModel>/numItems}" width="100%" id="itemCount"/><Table items="{path:'myModel>/objects'}" noDataText="No data from repository available" id="myRepoTable" busy="true">
  <items>
	<ColumnListItem counter="0" id="item1">
	<cells>
		<Text id="text5" maxLines="0" text="{path:'myModel>/properties/cmis:objectId/displayName'}"/>
		<Text id="text6" maxLines="0" text="{myModel>/properties/['cmis:objectId']/displayName}"/>
		<Text id="text7" maxLines="0" text="{myModel>properties/cmis:objectId/id}"/>
                <Text id="text8" maxLines="0" text="{/properties/cmis:objectId/id}"/>
<Text id="text9" maxLines="0" text="{properties/['cmis:objectId']/id}"/> </cells> </ColumnListItem> </items> ...

My question is: How I'm able to select the displayName in the properties of an object, so the path to it is: objects -> object -> properties -> cmis:objectid -> displayName

Thanks!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Feb 10, 2017 at 05:56 PM
0

Guess you are missing the "object" node in the absolute path. Please try adding that.

<Text id="text6" maxLines="0" text="{myModel>/object/properties/['cmis:objectId']/displayName}"/>

Not sure how we can mention "cmis:objectId" though.

Share
10 |10000 characters needed characters left characters exceeded
Srikanth KV Feb 10, 2017 at 05:59 PM
0

When binding an aggregation(items) then child controls in the aggregation refers to relative binding path.

you can adjust the code like below.

<Table items="{myModel>/objects}">
  <items>
     <ColumnListItem>
      <cells>
           <Text text="{myModel>object/properties/cmis:objectId/displayName}" />
      </cells>
     </ColumnListItem>
  </items>
</Table>
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 16, 2017 at 02:20 PM
0

Thank you! Indeed the "object" was missing!

Share
10 |10000 characters needed characters left characters exceeded