Skip to Content

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

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();

		}

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Aug 22, 2017 at 10:00 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 23, 2017 at 08:07 AM

    Please go through this controller code.

    ValueHelpDialogCode

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 23, 2017 at 03:17 PM

    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.


    Add comment
    10|10000 characters needed characters exceeded