on 2014 May 27 10:57 PM
I get the following error - "Unable to get value of the property 'getElementsByTagName':object is null or undefined
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta name="description" content="UI5 table example with local JSON model" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<TITLE>SAPUI5 Projects Status - Applications</TITLE>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"
type="text/javascript" src="/sapui5/resources/sap-ui-core.js" data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.ui.commons,sap.ui.table">
</SCRIPT>
<script>
var xmlHttp = new XMLHttpRequest();
var xmlDOM;
xmlHttp.open("GET","ProjectsStatus/Transactions/ProjectsStatus", false);
xmlHttp.send();
xmlDOM = xmlHttp.responseXML.documentElement;
var opElement = xmlDOM.getElementsByTagName("Row")[0].firstChild; <<<<<< I get error here - 'getElementsByTagName':object is null or undefined
var aData = eval(opElement.firstChild.data);
/* Define the table, with toolbar controls, update button */
var oTable = new sap.ui.table.DataTable("table", {
editable : true,
visibleRowCount :5
});
oTable.setSelectionMode(sap.ui.table.SelectionMode.Multi);
oTable.setToolbar(new sap.ui.commons.Toolbar({items: [
new sap.ui.commons.Button({text: "Update Data", press: updateData}),
new sap.ui.commons.Label({text: "First Visible Row"}),
new sap.ui.commons.TextField({tooltip: "First Visible Row", width: "30px", change: function(oEvent) { oTable.setFirstVisibleRow(parseInt(oEvent.getParameter("newValue"))); }}),
new sap.ui.commons.Label({text: "Visible Row Count"}),
new sap.ui.commons.TextField({tooltip: "Visible Row Count", width: "30px", change: function(oEvent) { oTable.setVisibleRowCount(parseInt(oEvent.getParameter("newValue"))); }})
]}));
/* Define the table columns */
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
/* Define the JSON model */
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
/* Connect the data table to the JSON model */
oTable.setModel(oModel);
oTable.bindRows("modelData");
oTable.placeAt("content");
/* Function to save the updated data in the grid.*/
function updateData() {
/* get the selected row context and using the context read the required values from the selected row*/
var selRowContext = oTable.getContextByIndex(oTable.getSelectedIndex());
var selectedId = oModel.getProperty("giid", selRowContext);
var selectedApp = oModel.getProperty("application", selRowContext);
var selectedDate = oModel.getProperty("datedue", selRowContext);
document.icmd_common.setQueryTemplate("ProjectsStatus/MDO_Transactions/Projects_MDO_Select");
var commCommandQueryTemplate = document.icmd_common.getQueryObject();
commCommandQueryTemplate.setParam(1, selectedApplications);
commCommandQueryTemplate.setParam(2,selectedPercentComplete);
commCommandQueryTemplate.setParam(3, selectedDate_Due);
commCommandQueryTemplate.setParam(4, selectedTesting_Due);
document.icmd_common.executeCommand();
/* Display a success message */
sap.ui.commons.MessageBox.alert("Actual quantity updated successfully."); }
</script>
</head>
<body class='sapUiBody'>
<h><b>Applications</b></h><br><br>
<table style="width:100%">
<div id='content1'></div>
</table> <br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Applications Changes</b></h><br><br>
<table style="width:100%">
<div id='content2'></div>
</table><br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Infrastructure Changes</b></h><br><br>
<table style="width:100%">
<div id='content3'></div>
</table><br><br><br>
</body>
</html>
Request clarification before answering.
It seems below statement do not hold any value . Verify if Row[0].firstChild is mapped correctly and you are getting some value from this object.
xmlDOM.getElementsByTagName("Row")[0].firstChild.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I changed the code a little. Where I am trying to bind the table data. I have 3 tables in one page.
I am only testing the first table.
When I try to bind it - it gives "no data" error - yet it displays the column names.
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta name="description" content="UI5 table example with local JSON model" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<TITLE>SAPUI5 Projects Status - Applications</TITLE>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"
type="text/javascript" src="/sapui5/resources/sap-ui-core.js" data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.ui.commons,sap.ui.table">
</SCRIPT>
<script>
function PageLoad()
{
GetMDoData();
}
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "WVL BOD 9212", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/23/2014" },
{Applications: "WVL BOD 9211", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/24/2014" },
{Applications: "WVL BOD 3303", PercentComplete: "75", Date_Due: "6/16/2016", Testing_Due: "6/25/2014" },
{Applications: "ETW BOD 3304", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/26/2014" },
{Applications: "CLE BOD 1902", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/27/2014" },
{Applications: "ISO HAZ", PercentComplete: "80", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "ISO CWO", PercentComplete: "80", Date_Due: "6/01/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 3 Stream ", PercentComplete: "60", Date_Due: "6/29/2014", Testing_Due: "" },
{Applications: "ISO Integration", PercentComplete: "10", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 7 QM Charts", PercentComplete: "15", Date_Due: "6/15/2014", Testing_Due: "" },
{Applications: "SCB PCO", PercentComplete: "100", Date_Due: "?", Testing_Due: "" },
{Applications: "SCB Top Chart ", PercentComplete: "10", Date_Due: "5/20/2014", Testing_Due: "" },
{Applications: "Project Status", PercentComplete: "25", Date_Due: "7/25/2014", Testing_Due: "" },
{Applications: "WVL LOI", PercentComplete: "100", Date_Due: "4/20/2014", Testing_Due: ""},
{Applications: "DSS (HTML5)", PercentComplete: "100", Date_Due: "3/31/2013", Testing_Due: ""},
{Applications: "ETW 3304 BOD Pilot",PercentComplete: "100", Date_Due: "11/16/2013", Testing_Due: ""},
{Applications: "HTMl 5 Table Tools",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
{Applications: "ISO JAX",PercentComplete: "100", Date_Due: "7/31/2013", Testing_Due: ""},
{Applications: "ISO FEN",PercentComplete: "100", Date_Due: "1/10/2014", Testing_Due: ""},
{Applications: "WVL QM Display",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
];
/* =================================== */
/* Obtain Json object filled with Data* <<<<<< This is where it shows "no data" in the table
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
xmlDom= xmlHttp.responseXML;
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: xmlDom});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content1");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "ISO IE11 BUG FIXES", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "ISO Fernley TimeOut", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "IE 11 Testing", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "IE 11 Testing_ISO Application", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_ISO DSS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_BOD/EPAmericas", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_TOOLS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_STATUS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content2");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "CIMX", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Connections", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - NWDI", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Security", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Integration", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content3");
</script>
</head>
<body class='sapUiBody'>
<h><b>Applications</b></h><br><br>
<table style="width:100%">
<div id='content1'></div>
</table> <br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Applications Changes</b></h><br><br>
<table style="width:100%">
<div id='content2'></div>
</table><br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Infrastructure Changes</b></h><br><br>
<table style="width:100%">
<div id='content3'></div>
</table><br><br><br>
</body>
</html>
You might be able to get more help if you post over in the SAP UI5 forum:
http://scn.sap.com/community/developer-center/front-end/content
Hi Amr,
The MII Runner service call that you make to run your transaction returns xml data.
Hence the sap ui5 data model you should be using is sap.ui.model.xml.XMLModel()
By modifying your code a little as shown below I got it to work:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta name="description" content="UI5 table example with local JSON model" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<TITLE>SAPUI5 Projects Status - Applications</TITLE>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"
type="text/javascript" src="/sapui5/resources/sap-ui-core.js" data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.ui.commons,sap.ui.table">
</SCRIPT>
<script>
function PageLoad()
{
GetMDoData();
}
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "WVL BOD 9212", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/23/2014" },
{Applications: "WVL BOD 9211", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/24/2014" },
{Applications: "WVL BOD 3303", PercentComplete: "75", Date_Due: "6/16/2016", Testing_Due: "6/25/2014" },
{Applications: "ETW BOD 3304", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/26/2014" },
{Applications: "CLE BOD 1902", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/27/2014" },
{Applications: "ISO HAZ", PercentComplete: "80", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "ISO CWO", PercentComplete: "80", Date_Due: "6/01/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 3 Stream ", PercentComplete: "60", Date_Due: "6/29/2014", Testing_Due: "" },
{Applications: "ISO Integration", PercentComplete: "10", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 7 QM Charts", PercentComplete: "15", Date_Due: "6/15/2014", Testing_Due: "" },
{Applications: "SCB PCO", PercentComplete: "100", Date_Due: "?", Testing_Due: "" },
{Applications: "SCB Top Chart ", PercentComplete: "10", Date_Due: "5/20/2014", Testing_Due: "" },
{Applications: "Project Status", PercentComplete: "25", Date_Due: "7/25/2014", Testing_Due: "" },
{Applications: "WVL LOI", PercentComplete: "100", Date_Due: "4/20/2014", Testing_Due: ""},
{Applications: "DSS (HTML5)", PercentComplete: "100", Date_Due: "3/31/2013", Testing_Due: ""},
{Applications: "ETW 3304 BOD Pilot",PercentComplete: "100", Date_Due: "11/16/2013", Testing_Due: ""},
{Applications: "HTMl 5 Table Tools",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
{Applications: "ISO JAX",PercentComplete: "100", Date_Due: "7/31/2013", Testing_Due: ""},
{Applications: "ISO FEN",PercentComplete: "100", Date_Due: "1/10/2014", Testing_Due: ""},
{Applications: "WVL QM Display",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
];
/* =================================== */
/* Obtain Json object filled with Data* <<<<<< This is where it shows "no data" in the table
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
// xmlDom= xmlHttp.responseXML;
xmlDom = xmlHttp.responseText;
// create a JSONModel, fill in the data and bind the Table to this model
// var oModel = new sap.ui.model.json.JSONModel();
var oModel = new sap.ui.model.xml.XMLModel();
//oModel.setData({modelData: xmlDom});
oModel.setXML(xmlDom);
oTable.setModel(oModel);
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
// finally place the Table into the UI
oTable.placeAt("content1");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "ISO IE11 BUG FIXES", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "ISO Fernley TimeOut", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "IE 11 Testing", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "IE 11 Testing_ISO Application", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_ISO DSS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_BOD/EPAmericas", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_TOOLS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_STATUS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content2");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "CIMX", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Connections", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - NWDI", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Security", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Integration", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content3");
</script>
</head>
<body class='sapUiBody'>
<h><b>Applications</b></h><br><br>
<table style="width:100%">
<div id='content1'></div>
</table> <br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Applications Changes</b></h><br><br>
<table style="width:100%">
<div id='content2'></div>
</table><br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Infrastructure Changes</b></h><br><br>
<table style="width:100%">
<div id='content3'></div>
</table><br><br><br>
</body>
</html>
You will have to appropriately change the below in the above code:
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
The code that was modified is marked and is in bold.
Hope this helps!
Regards,
Ria
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta name="description" content="UI5 table example with local JSON model" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<TITLE>SAPUI5 Projects Status - Applications</TITLE>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"
type="text/javascript" src="/sapui5/resources/sap-ui-core.js" data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.ui.commons,sap.ui.table">
</SCRIPT>
<script>
function PageLoad()
{
GetMDoData();
}
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "WVL BOD 9212", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/23/2014" },
{Applications: "WVL BOD 9211", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/24/2014" },
{Applications: "WVL BOD 3303", PercentComplete: "75", Date_Due: "6/16/2016", Testing_Due: "6/25/2014" },
{Applications: "ETW BOD 3304", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/26/2014" },
{Applications: "CLE BOD 1902", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/27/2014" },
{Applications: "ISO HAZ", PercentComplete: "80", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "ISO CWO", PercentComplete: "80", Date_Due: "6/01/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 3 Stream ", PercentComplete: "60", Date_Due: "6/29/2014", Testing_Due: "" },
{Applications: "ISO Integration", PercentComplete: "10", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 7 QM Charts", PercentComplete: "15", Date_Due: "6/15/2014", Testing_Due: "" },
{Applications: "SCB PCO", PercentComplete: "100", Date_Due: "?", Testing_Due: "" },
{Applications: "SCB Top Chart ", PercentComplete: "10", Date_Due: "5/20/2014", Testing_Due: "" },
{Applications: "Project Status", PercentComplete: "25", Date_Due: "7/25/2014", Testing_Due: "" },
{Applications: "WVL LOI", PercentComplete: "100", Date_Due: "4/20/2014", Testing_Due: ""},
{Applications: "DSS (HTML5)", PercentComplete: "100", Date_Due: "3/31/2013", Testing_Due: ""},
{Applications: "ETW 3304 BOD Pilot",PercentComplete: "100", Date_Due: "11/16/2013", Testing_Due: ""},
{Applications: "HTMl 5 Table Tools",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
{Applications: "ISO JAX",PercentComplete: "100", Date_Due: "7/31/2013", Testing_Due: ""},
{Applications: "ISO FEN",PercentComplete: "100", Date_Due: "1/10/2014", Testing_Due: ""},
{Applications: "WVL QM Display",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
];
/* =================================== */
/* Obtain Json object filled with Data* <<<<<< This is where it shows "no data" in the table
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
xmlDom= xmlHttp.responseXML;
// xmlDom = xmlHttp.responseText;
// create a JSONModel, fill in the data and bind the Table to this model
// var oModel = new sap.ui.model.json.JSONModel();
var oModel = new sap.ui.model.xml.XMLModel();
oModel.setData({modelData: xmlDom});
oModel.setXML(xmlDom);
oTable.setModel(oModel);
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
// finally place the Table into the UI
oTable.placeAt("content1");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "ISO IE11 BUG FIXES", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "ISO Fernley TimeOut", PercentComplete: "0", Date_Due: "6/1/2014", Testing_Due: "" },
{Applications: "IE 11 Testing", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "IE 11 Testing_ISO Application", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_ISO DSS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_BOD/EPAmericas", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_TOOLS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
{Applications: "IE 11 Testing_STATUS", PercentComplete: "100", Date_Due: "5/16/2014", Testing_Due: "5/16/214" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content2");
</script>
<script>
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "CIMX", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMX - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMID - Integration", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIMIP - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1", PercentComplete: "99.5", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Security", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM1 - Integration", PercentComplete: "98", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM2 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Connections", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - NWDI", PercentComplete: "100", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Security", PercentComplete: "90", Date_Due: "", Testing_Due: "" },
{Applications: "CIM3 - Integration", PercentComplete: "50", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4", PercentComplete: "85", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Connections", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - NWDI", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Security", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
{Applications: "CIM4 - Integration", PercentComplete: "0", Date_Due: "", Testing_Due: "" },
];
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content3");
</script>
</head>
<body class='sapUiBody'>
<h><b>Applications</b></h><br><br>
<table style="width:100%">
<div id='content1'></div>
</table> <br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Applications Changes</b></h><br><br>
<table style="width:100%">
<div id='content2'></div>
</table><br><br><br>
</body>
<body class='sapUiBody'>
<h><b>Infrastructure Changes</b></h><br><br>
<table style="width:100%">
<div id='content3'></div>
</table><br><br><br>
</body>
</html>
Hi Amr,
Your above code looks different from the one that I had modified based on your original code. I think the code that I had modified earlier should work fine for you just by changing the below line appropriately:
oTable.bindRows("/element");
Can you please share a screen shot of the xml structure that the transaction returns. That might help in debugging the code.
Regards,
Ria
I modified the code just to show for table 1 - also below the code for table 1 is actually a json structure from the xml:
<!DOCTYPE HTML>
<HTML>
<HEAD>
<meta name="description" content="UI5 table example with local JSON model" />
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<META http-equiv='cache-control' content='no-cache'>
<META http-equiv='expires' content='0'>
<META http-equiv='pragma' content='no-cache'>
<TITLE>SAPUI5 Projects Status - Applications</TITLE>
<h><b>Applications</b></h><br><br>
<SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"
type="text/javascript" src="/sapui5/resources/sap-ui-core.js" data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.core,sap.ui.commons,sap.ui.commons,sap.ui.table">
</SCRIPT>
<script>
function PageLoad()
{
GetMDoData();
}
// create the DataTable control
var oTable = new sap.ui.table.Table({editable:true});
// define the Table columns
var oControl = new sap.ui.commons.TextView({text:"{Applications}"}); // short binding notation
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Applications"}), template: oControl, sortProperty: "lastName", filterProperty: "lastName", width: "100px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "PercentComplete"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "PercentComplete"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Date_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Date_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
oControl = new sap.ui.commons.TextField().bindProperty("value", "Testing_Due"); // more verbose binding notationt
oTable.addColumn(new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Testing_Due"}), template: oControl, sortProperty: "name", filterProperty: "name", width: "80px"}));
// create some local data
var aData = [
{Applications: "WVL BOD 9212", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/23/2014" },
{Applications: "WVL BOD 9211", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/24/2014" },
{Applications: "WVL BOD 3303", PercentComplete: "75", Date_Due: "6/16/2016", Testing_Due: "6/25/2014" },
{Applications: "ETW BOD 3304", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/26/2014" },
{Applications: "CLE BOD 1902", PercentComplete: "75", Date_Due: "6/16/2014", Testing_Due: "6/27/2014" },
{Applications: "ISO HAZ", PercentComplete: "80", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "ISO CWO", PercentComplete: "80", Date_Due: "6/01/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 3 Stream ", PercentComplete: "60", Date_Due: "6/29/2014", Testing_Due: "" },
{Applications: "ISO Integration", PercentComplete: "10", Date_Due: "6/1/2014", Testing_Due: "6/8/2014" },
{Applications: "WVL 7 QM Charts", PercentComplete: "15", Date_Due: "6/15/2014", Testing_Due: "" },
{Applications: "SCB PCO", PercentComplete: "100", Date_Due: "?", Testing_Due: "" },
{Applications: "SCB Top Chart ", PercentComplete: "10", Date_Due: "5/20/2014", Testing_Due: "" },
{Applications: "Project Status", PercentComplete: "25", Date_Due: "7/25/2014", Testing_Due: "" },
{Applications: "WVL LOI", PercentComplete: "100", Date_Due: "4/20/2014", Testing_Due: ""},
{Applications: "DSS (HTML5)", PercentComplete: "100", Date_Due: "3/31/2013", Testing_Due: ""},
{Applications: "ETW 3304 BOD Pilot",PercentComplete: "100", Date_Due: "11/16/2013", Testing_Due: ""},
{Applications: "HTMl 5 Table Tools",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
{Applications: "ISO JAX",PercentComplete: "100", Date_Due: "7/31/2013", Testing_Due: ""},
{Applications: "ISO FEN",PercentComplete: "100", Date_Due: "1/10/2014", Testing_Due: ""},
{Applications: "WVL QM Display",PercentComplete: "100", Date_Due: "2/12/2014", Testing_Due: ""},
];
/* =================================== */
/* Obtain Json object filled with Data*
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
xmlDom= xmlHttp.responseXML;
// xmlDom = xmlHttp.responseText;
// create a JSONModel, fill in the data and bind the Table to this model
// var oModel = new sap.ui.model.json.JSONModel();
var oModel = new sap.ui.model.xml.XMLModel();
oModel.setData({modelData: xmlDom});
oModel.setXML(xmlDom);
oTable.setModel(oModel);
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
// finally place the Table into the UI
oTable.placeAt("content1");
</script>
</head>
<body class='sapUiBody'>
<div id='content1'></div>
</body>
</html>
********************************** Json Structure from the XML ********************
| [INFO] [Tracer_1] | ||||||
| [{ | ||||||
| Applications: "BOD ETW 3304", | ||||||
| PercentComplete: "85", | ||||||
| Date_Due: "2014-06-16T11:25:00", | ||||||
| Testing_Due: "" }, { | ||||||
| Applications: "BOD ETW 3304", | ||||||
| PercentComplete: "85", | ||||||
| Date_Due: "2014-06-16T11:25:00", | ||||||
| Testing_Due: "" }, { | ||||||
| Applications: "BOD WLV9212", | ||||||
| PercentComplete: "85", | ||||||
| Date_Due: "2014-06-16T11:25:00", | ||||||
| Testing_Due: "" }, { | ||||||
| Applications: "BOD WLV9212", | ||||||
| PercentComplete: "85", | ||||||
| Date_Due: "2014-06-16T11:25:00", | ||||||
| Testing_Due: "" }, { | ||||||
| Applications: "BOD ETW 3303", | ||||||
| PercentComplete: "85", | ||||||
| Date_Due: "2014-06-16T11:25:00", | ||||||
| Testing_Due: "" }]; |
The service call gives you xml data right, hence the data model that you should be using is sap.ui.model.xml.XMLModel() and likewise the method you should be using on the model object is setXML(xmldata).
The xmldata you can get by calling xmlDom = xmlHttp.responseText;
And for binding the rows you should calling oTable.bindRows("/element"); where element is the root node of the xml structure that forms each row:
<root>
<element>
<Applications>WVL BOD 9212</Applications>
<PercentComplete>75</PercentComplete>
<Date_Due>6/16/2014</Date_Due>
<Testing_Due>6/23/2014</Testing_Due>
</element>
<element>
<Applications>WVL BOD 9211</Applications>
<PercentComplete>75</PercentComplete>
<Date_Due>6/16/2014</Date_Due>
<Testing_Due>6/24/2014</Testing_Due>
</element>
...
</root>
Hope this helps you.
Regards,
Ria
So is the following correct?
/* =================================== */
/* Obtain XML object filled with Data*
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
xmlDom = xmlHttp.responseText;
// create a JSONModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.xml.XMLModel();
oModel.setData({modelData: xmlDom});
oModel.setXML(xmlDom);
oTable.setModel(oModel);
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
// finally place the Table into the UI
oTable.placeAt("content1");
Below is the code that you might have to use:
/* =================================== */
/* Obtain XML object filled with Data*
/* =================================== */
var xmlHttp = new XMLHttpRequest();
var xmlDom;
xmlHttp.open( "GET", "/XMII/Runner?Transaction=ProjectsStatus/Transactions/ProjectsStatus&OutputParameter=JSONData&Content-Type=text/xml", false );
xmlHttp.send();
xmlDom = xmlHttp.responseText;
// create a XMLModel, fill in the data and bind the Table to this model
var oModel = new sap.ui.model.xml.XMLModel();
//oModel.setData({modelData: xmlDom});
oModel.setXML(xmlDom);
oTable.setModel(oModel);
oTable.bindRows("/element"); //where element is the node that represents that data which forms each row of the table
// finally place the Table into the UI
oTable.placeAt("content1");
You might have to change this statement : oTable.bindRows("/element"); based on the structure of the xml returned by the service. You can post the xml structure like the one I have added in my previous reply, that might help me check if your code is right.
Regards,
Ria
Please post a screenshot of your xml structure. Make sure your xml has a root node under which you have all the child elements which will form the rows of your sap ui5 table, only then bindRows() will work.
I created an xml for the data that you have used in your example code and the structure looks like this:
<rootnode>
<element>
<Applications>WVL BOD 9212</Applications>
<PercentComplete>75</PercentComplete>
<Date_Due>6/16/2014</Date_Due>
<Testing_Due>6/23/2014</Testing_Due>
</element>
<element>
<Applications>WVL BOD 9211</Applications>
<PercentComplete>75</PercentComplete>
<Date_Due>6/16/2014</Date_Due>
<Testing_Due>6/24/2014</Testing_Due>
</element>
...
</rootnode>
The xml that you are binding to the model should have a root node similar to the rootnode tag in the above case.
Do let me know if it still doesn't work for you.
Regards,
Ria
You still do not understand.....we have to use the JSON model. - sap.ui.model.json.JSONModel()
The xml file already got converted to JSON.
Also in the XML file it does not have an element.
The following XML is what we have:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="ProjectsStatus_Applications.xsl"?>
<Rowsets CachedTime="" DateCreated="2014-05-12T10:31:48" EndDate="2014-05-12T10:31:48" StartDate="2014-05-12T09:31:48" Version="14.0 SP4 Patch 1 (Jan 8, 2014)">
<Rowset>
<Columns>
<Column Description="Applications Name" MaxRange="100" MinRange="0" Name="Applications" SQLDataType="12" SourceColumn="Jobs"/>
<Column Description="" MaxRange="100" MinRange="0" Name="PercentComplete" SQLDataType="4" SourceColumn="PercentComplete"/>
<Column Description="Date in ascending order" MaxRange="100" MinRange="0" Name="DateDue" SQLDataType="93" SourceColumn="DateDue"/>
<Column Description="" MaxRange="100" MinRange="0" Name="TestingDue" SQLDataType="12" SourceColumn="TestingDue"/>
</Columns>
<Row>
<Applications>WVL BOD 9212</Applications>
<PercentComplete>75</PercentComplete>
<DateDue>6/16/2014</DateDue>
<TestingDue>6/23/2014</TestingDue>
</Row>
<Row>
<Applications>WVL BOD 9211</Applications>
<PercentComplete>75</PercentComplete>
<DateDue>6/16/2014</DateDue>
<TestingDue>6/24/2014</TestingDue>
</Row>
<Row>
<Applications>ETW BOD 3303</Applications>
<PercentComplete>75</PercentComplete>
<DateDue>6/16/2014</DateDue>
<TestingDue>6/25/2014</TestingDue>
</Row>
<Row>
<Applications>ETW BOD 3304</Applications>
<PercentComplete>75</PercentComplete>
<DateDue>6/16/2014</DateDue>
<TestingDue>6/26/2014</TestingDue>
</Row>
<Row>
<Applications>CLE BOD 1902</Applications>
<PercentComplete>75</PercentComplete>
<DateDue>6/16/2014</DateDue>
<TestingDue>6/27/2014</TestingDue>
</Row>
<Row>
<Applications>ISO HAZ</Applications>
<PercentComplete>80</PercentComplete>
<DateDue>6/1/2014</DateDue>
<TestingDue>6/8/2014</TestingDue>
</Row>
<Row>
<Applications>ISO CWO</Applications>
<PercentComplete>80</PercentComplete>
<DateDue>6/1/2014</DateDue>
<TestingDue>6/8/2014</TestingDue>
</Row>
<Row>
<Applications>WVL 3 Stream</Applications>
<PercentComplete>60</PercentComplete>
<DateDue>6/29/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>ISO Integration</Applications>
<PercentComplete>10</PercentComplete>
<DateDue>6/1/2014</DateDue>
<TestingDue>6/8/2014</TestingDue>
</Row>
<Row>
<Applications>WVL 7 QM Charts</Applications>
<PercentComplete>15</PercentComplete>
<DateDue>6/15/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>SCB PCO</Applications>
<PercentComplete>10</PercentComplete>
<DateDue></DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>SCB Top Chart</Applications>
<PercentComplete>95</PercentComplete>
<DateDue>5/20/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>Project Status</Applications>
<PercentComplete>25</PercentComplete>
<DateDue>7/25/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>WVL LOI</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>4/20/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>DSS (HTML5)</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>3/31/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>ETW 3304 BOD Pilot</Applications>
<PercentComplete100></PercentComplete>
<DateDue>11/16/2013</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>HTMl 5 Table Tools</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>2/12/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>ISO JAX</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>7/31/2013</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>ISO FEN</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>1/10/2014</DateDue>
<TestingDue></TestingDue>
</Row>
<Row>
<Applications>WVL QM Display</Applications>
<PercentComplete>100</PercentComplete>
<DateDue>2/12/2014</DateDue>
<TestingDue></TestingDue>
</Row>
</Rowset>
</Rowsets>
Than it got converted to the following JSON:
[{
Applications: "BOD ETW 3304",
PercentComplete: "85",
Date_Due: "2014-06-16T11:25:00",
Testing_Due: "" }, {
Applications: "BOD ETW 3304",
PercentComplete: "85",
Date_Due: "2014-06-16T11:25:00",
Testing_Due: "" }, {
Applications: "BOD WLV9212",
PercentComplete: "85",
Date_Due: "2014-06-16T11:25:00",
Testing_Due: "" }, {
Applications: "BOD WLV9212",
PercentComplete: "85",
Date_Due: "2014-06-16T11:25:00",
Testing_Due: "" }, {
Applications: "BOD ETW 3303",
PercentComplete: "85",
Date_Due: "2014-06-16T11:25:00",
Testing_Due: "" }];
Now we need to display above using SAPUI5 JSON Table Binding with the following headings: -as you can see - right now it is not displaying any data.
Hi Amr,
I tried your example with JSON model (sap.ui.model.json.JSONModel() )
var jsonObj = [{
"Applications": "BOD ETW 3304",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD ETW 3304",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD WLV9212",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD WLV9212",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD ETW 3303",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }];
var obj = new Object();
obj.rows = jsonObj; //Adding root attribute "rows" for the json object to be used as parameter to bindRows()
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(obj);
oTable.setModel(oModel);
oTable.bindRows("/rows");
Please check if the above code works for you (and hope I have understood your query).
Regards,
Ria
May be you could give this below piece of code a final try:
//jsonObj - javascript variable that holds your json data
var jsonObj = [{
"Applications": "BOD ETW 3304",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD ETW 3304",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD WLV9212",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD WLV9212",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }, {
"Applications": "BOD ETW 3303",
"PercentComplete": "85",
"Date_Due": "2014-06-16T11:25:00",
"Testing_Due": "" }];
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData : jsonObj}); //Assign the javascript variable "jsonObj" that holds your json data to binding variable that will be used in bindRows() of table
oTable.setModel(oModel);
oTable.bindRows("/modelData");
// finally place the Table into the UI
oTable.placeAt("content1");
Regards,
Ria
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.