Skip to Content
0

How do I implement simple value help in UI5 from OData?

Aug 15, 2017 at 02:15 PM

86

avatar image

My goal is to populate a simple key and text value help from my odata service. I have already verified that the odata.results table from /ColorCodeSet is populated in the success function below. The column headers appear in the value help dialog, but none of my column rows appear. Any suggestions?

valueHelpColor : function(oEvent) {
	debugger;
	if(!this._oValueHelpDialog){
		this._oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog("idValueHelp"),{
		key: "ColorCd",
		descriptionKey: "ColorDesc",
		ok: function(oEvent){
					},
					cancel: function(){						}
				}
			};

			var that = this;
			this.getModel("easter").read("/ColorCodeSet",{
				async : false,
				success : function(oData, response){
		if(oData.results.length === 0){
			return;
					};
var oColModel = new sap.ui.model.json.JSONModel();
	oColModel.setData({
cols: [					
{label: "Color Code", template: "ColorCd"},	
{label: "Color Desc", template: "ColorDesc"}
						]
					});
var oTable = that._oValueHelpDialog.getTable();
oTable.setModel(oColModel, "columns");
var oColorData = new sap.ui.model.json.JSONModel(oData.results);
		oTable.setModel(oColorData);
		that._oValueHelpDialog.open();

				},

				error: function(oError){

					alert("oData Read failed");

				}				

			});

			

			

			//this._oValueHelpDialog.open();

		}

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

3 Answers

Anurag Mundra Aug 22, 2017 at 10:00 AM
0

Can you please share the screenshot of value help you are getting currently?

Share
10 |10000 characters needed characters left characters exceeded
Irfan Gokak Aug 23, 2017 at 08:07 AM
0

Please go through this controller code.

ValueHelpDialogCode

Share
10 |10000 characters needed characters left characters exceeded
Sharath M G Aug 23, 2017 at 03:17 PM
0

Generic suggestions:

Keep the code simple. On success, load the model by setting the data.

Maintain code to build the table layout outside of oData call. Then, check if table appears and then confirm if data is getting retrieved.

If both happen, then it's down to data binding of the model to table.

Refer to samples in Explored link.


Share
10 |10000 characters needed characters left characters exceeded