cancel
Showing results for 
Search instead for 
Did you mean: 

onBefore/AfterRendering in combobox.

Former Member
0 Kudos

Hi,

I have one table which is tied to one ODataModel. Now in the table one of the columns is 'ComboBox' which is tied to one of the properties in the model.

Depending upon some other property I am supposed to make this combobox editable.

For that I tried using 'formatter' function and 'onBefore/AfterRendering' call back as follows. None of them worked. It was strange to know that 'onBeforeRendering'/'onAfterRendering' doesn't get called.

Find my code below:

var combo = new sap.ui.commons.ComboBox({

  editable: false,

   valueState:{

  parts:["/StatusText","/EndDate"],

  formatter: function(oVal1, oVal2){

  console.log('calling formatter');

  console.log("oVal1"+oVal1); // this is undefined

  console.log("oVal2"+oVal2);// this is also undefined

  if(oVal2){

  this.setEditable(true);

  }

  return sap.ui.core.ValueState.None;

  }

  },

  onAfterRendering: function(arg1, arg2){

  console.log('onBeforeRendering:: function()');

  console.log(arg1);

  console.log(arg2);

  },

  items: [

                                  new sap.ui.core.ListItem({text: "New",key:"0"}),

                                  new sap.ui.core.ListItem({text: "In Process",key:"1"}),

                                  new sap.ui.core.ListItem({text: "Complete",key:"2"}),

                                  new sap.ui.core.ListItem({text: "On hold",key:"3"}),

                                  new sap.ui.core.ListItem({text: "Cancelled",key:"4"}),

                                  new sap.ui.core.ListItem({text: "Rejected",key:"5"}),

                                  new sap.ui.core.ListItem({text: "In review",key:"6"}),

                                  new sap.ui.core.ListItem({text: "Approved",key:"7"}),

                                  new sap.ui.core.ListItem({text: "Approved by SD",key:"8"}),

                                  new sap.ui.core.ListItem({text: "Rejected by SD",key:"9"})

                                  ]}).bindProperty("value","StatusText").bindProperty("selectedKey","Status")

                                  .attachChange({name :sProperty},this.change);

  column.setTemplate(combo);

Any Help will be appreciated.

Thanks,

Supriya Kale

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182862
Active Contributor
0 Kudos

hi Supriya

Move the onAfterRendering method out like this.


combo.onAfterRendering: function() {

  if (sap.ui.commons.ComboBox.prototype.onAfterRendering) {

       // have to call control's onAfterRendering method if there is one.

      sap.ui.commons.ComboBox.prototype.onAfterRendering.apply(this);

  }

  console.log('onAfterRendering:: function()');

};

-D