Skip to Content
0

Unable to bind TableSelectDialog . Getting empty table .

May 23, 2017 at 01:49 PM

198

avatar image
novalue.jpg
onpressTableDialogfunction : function()

{
 	var sSelectedItemText = this.byId("POInput").getValue();
 	
 	 var oTableSelectDialog4 = new sap.m.TableSelectDialog( {
			title: "Inbound Delivery Details",
	
		
			multiSelect : true,
		
			columns : [
				new sap.m.Column({
					hAlign: "Begin",
					header: new sap.m.Label({
						text: "Inbound Delivery "
					})
				})
			
			], 
			items :
			[new sap.m.ColumnListItem({
					cells:[
					new sap.m.Text({
					text :"{InboundDelivery}"
				})
					]	
			})
							]
		});
		
		
		var sJson12 = {};
			var oModel1 = new sap.ui.model.json.JSONModel();
		this.oApplicationFacade.getApplicationModel("oData").read("GR4PO_DL_Headers('" + sSelectedItemText + "')/?$expand=Header2Items",
				null,
				null,
				false,
				function(oData, oResponse) {
						
sJson12.InboundDelivery = oData.Header2Items.results[0].InboundDelivery;
// Check header for backend system errors
var oHeader = oResponse.headers["sap-message"];
			if (oHeader) {
			var oJson = JSON.parse(oHeader);
				if (oJson.code) {
		sap.ca.ui.message.showMessageBox({
			type: sap.ca.ui.message.Type.INFO,
		message: decodeURIComponent(oJson.message)
						}, null);

					
						}
					}
				}
					);
	oModel1.setData(sJson12);
oTableSelectDialog4.setModel(oModel1);
 console.log(sJson12, "2200004784");
		       
  oTableSelectDialog4.open();
 
 	
 }
novalue.jpg (45.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Akhilesh Upadhyay May 24, 2017 at 07:48 AM
0

do read like this,

var aFilters = [];
//use your filter property(Itemname) and value (Item1)
var oFilter = new sap.ui.model.Filter("ItemName", sap.ui.model.FilterOperator.EQ, "Item1"); 
aFilters.push(oFilter);
this.oApplicationFacade.getApplicationModel("oData").read("/GR4PO_DL_Headers", {
    filters : aFilters,
    urlParameters: {
        "$expand": "Header2Items"
    },
    null,
    null,
    false,
    function(oData, oResponse) {.............

And, aggregation binding as below,

var oTableSelectDialog4 = new sap.m.TableSelectDialog({
    title: "Inbound Delivery Details",
    multiSelect: true,
    columns: [
        new sap.m.Column({
            hAlign: "Begin",
            header: new sap.m.Label({
                text: "Inbound Delivery "
            })
        })
    ]
});

var oTemplate = new sap.m.ColumnListItem({
		cells:[new sap.m.Text({text:"{InboundDelivery}"})]

});


oTableSelectDialog4.setModel(oModel1);
oTableSelectDialog4.bindItems("/results", oTemplate); //check your data if data inside "results", if not do "/" only
Show 7 Share
10 |10000 characters needed characters left characters exceeded

if i am passing Filters in ,read url ( in Networks) is

/GR4PO_DL_Headers?$expand=Header2Items&$filter=InboundDelivery%20eq%20%272200004784%27

however it should be (to get value from odata)

/GR4PO_DL_Headers('2200004784')?$expand=Header2Items

let me know how can this be fixed

0
var sInboundDelivery = "2200004784";
this.oApplicationFacade.getApplicationModel("oData").read("/GR4PO_DL_Headers('" + sInboundDelivery  + "')", {
//filters: aFilters, //remove this line

try this.

0

i am able to read odata correctly but table is still not displaying values . let me know how can this be fixed


		var sSelectedItemText = this.byId("POInput").getValue();


		var oModel1 = new sap.ui.model.json.JSONModel();
		this.oApplicationFacade.getApplicationModel("oData").read("GR4PO_DL_Headers('" + sSelectedItemText + "')/?$expand=Header2Items",
			null,
			null,
			false,
			function(oData, oResponse) {
				oModel1.setData(oData);
				 console.log(oData, "Inside read");
				var oHeader = oResponse.headers["sap-message"];
				if (oHeader) {
					var oJson = JSON.parse(oHeader);
					if (oJson.code) {


						sap.ca.ui.message.showMessageBox({
							type: sap.ca.ui.message.Type.INFO,
							message: decodeURIComponent(oJson.message)
						}, null);


					}
				}
			}
		);
	
		var oTableSelectDialog4 = new sap.m.TableSelectDialog({
			title: "Inbound Delivery Details",
			multiSelect: true,
			columns: [
				new sap.m.Column({
					hAlign: "Begin",
					header: new sap.m.Label({
						text: "Inbound Delivery "
					})
				})
			]
		});


		var oTemplate = new sap.m.ColumnListItem({
			cells: [new sap.m.Text({
				text: "{InboundDelivery}"
			})]


		});


		oTableSelectDialog4.setModel(oModel1);
		oTableSelectDialog4.bindItems("/", oTemplate);


		
		oTableSelectDialog4.open();


	

0

pfb the table : it is showing rows but the value is not getting bind.

Console.log(oData); in read of odata .

0

try

oTableSelectDialog4.bindItems("/Header2Items/results", oTemplate);

0

please accept this thread as right answer that will be helpful for others :)

0

you closed this without accepted the right ans :p just mark it as right ans :)

0
Srikanth KV May 23, 2017 at 03:52 PM
0

Aggregation binding of 'items' is missing in your code

check the explored app

Show 1 Share
10 |10000 characters needed characters left characters exceeded

since i have to pass a value while reading odata also it has $expand , how can i bind this with items aggegation .?

.read("GR4PO_DL_Headers('" + sSelectedItemText + "')/?$expand=Header2Items"



0
Jasleen Kaur May 25, 2017 at 07:07 AM
0

yes it solved the issue . Thank you Akhilesh

Share
10 |10000 characters needed characters left characters exceeded