Skip to Content
0

How to view data using separate JSON files in SAPUI5

Nov 10, 2016 at 01:14 PM

58

avatar image

Hello Experts,

I have a Master Detail SAPUI5 application. I am able to navigate to Detail view successfully with the right information getting shown correctly. This is shown in the screenshot below

Among the information in the detail view includes a table used for navigation. the values are (deliberately) indicated as 100 100 100 but are supposed to be different.

Code for the table is:

<Table>
			<columns>
				<Column>
					<header><Label text="Click below to view" /></header>
				</Column>
				<Column
					minScreenWidth="Tablet"
					demandPopin="true"
					hAlign="Center" >
					<header><Label text="" /></header>
				</Column>
				<Column
					minScreenWidth="Tablet"
					demandPopin="true"
					hAlign="Center" >
					<header><Label text="" /></header>
				</Column>
				
			</columns>
			<ColumnListItem
				type="Navigation"
				press="handleLineItemPress" >
				<cells>
					<ObjectIdentifier
						title="{clientno}" />
					<Text
						text="{clientno}"/>
					<Text
						text="{clientno}"/>
					</cells>
			</ColumnListItem>
		</Table>

Also in the screenshot I have a tab that displays an empty table with columns such as Amount(money) Date Reason.

This table is supposed to display accumulated amounts for the clientno 100 who is the first one in the Master view. Also the table for navigation at the top of the detail view displays another view with the same table for accumulated amounts.

These two tables are NOT different. I need only one. I created both as I tried to work with suggestions over the Internet.

I have a database with two tables. One stores the data for the above tables (Amount Date Reason) and the other stores the data being displayed on the master and detail page minus the one on the above empty tables. I have two JSON files for the database tables. I have a client number as a unique key in the table for the master detail data. the second table uses auto increment as a unique key. it also has a client number but its not unique since the table is accumulating data from both the SAME and DIFFERENT clients. Hence, it might have same client number entry several times but different dates, reasons and amount(money).

This repeated entry of client number is the one I am using in my SQL statement to SELECT * FROM table_accumulate WHERE client_no = client number on the table at the top most part of the detail view e.g. 100 (Kindly check screenshot). This is the same 100 you see on the Master page.

The query results are in a separate JSON file.

This data is the one that should be displayed in the table with columns Amount Date Reason for client number 100.

How do I fetch data from the other JSON file to display in the table for client 100. Either in the detail view via the tab View Bills or clicking the navigation table to drill down to another view to see same data.

Below is what I tried to do unsuccessfully...

//i am able to get the 100 from the master view using the following in 
//the master controller


//var context = evt.getSource().getBindingContext();
		//this.nav.to("detail", context);

           var obj = evt.getSource();
	var oContext = obj.getBindingContext();
	var clientnol = oContext.getProperty("clientno");

console.log(clientnol); //this works

//I am able to get the value if i use the code above in the detail controller

How do I get to fetch data from the JSON file to display the accumulated Amounts Dates Reasons for client e.g. 100 in the empty table whose code is shown below.

<Table items="{/live}" 
			headerText=""
			>
			<columns>
				<Column>
					<header><Label text="Amount" /></header>
				</Column>
				<Column
					minScreenWidth="Tablet"
					demandPopin="true"
					hAlign="Center" >
					<header><Label text="Date" /></header>
				</Column>
				<Column
					minScreenWidth="Tablet"
					demandPopin="true"
					hAlign="Center" >
					<header><Label text="Reason" /></header>
				</Column>
				
			</columns>
			<ColumnListItem
				type="Navigation"
				press="handleLineItemPress" >
				<cells>
					<ObjectIdentifier
						title="{amount}" />
					<Text
						text="{date}"/>
					<Text
						text="{reason}"/>
					</cells>
			</ColumnListItem>
		</Table>

JSON files have got the following

file 1

contacts: [{clientno: "100", firstname: "joe", secondname: "joe", surname: "joe", totalexpected: "1122334455", paid: "1122334455", .........},

{clientno: "104", firstname: "doe", secondname: "doe", surname: "doe", totalexpected: "1122334455", paid: "1122334455", .........}

]

file 2

live: [{id: "1", clientno: "100", amount: "12345", reason: "Reason", note: "note", date: "2016-8-09 16:10:01" ........},

{id: "2", clientno: "100", amount: "54321", reason: "Reason", note: "note", date: "2016-11-09 16:10:01" ........},

{id: "2", clientno: "104", amount: "3443344", reason: "Reason ", note: "note", date: "2016-10-09 16:10:01" ........}

]

Many thanks for any help and suggestions

Dominic.

appview.png (87.1 kB)
empty.png (5.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers