melomg
melomg

Reputation: 748

Why isn't my view re-rendered again as expected?

I created a custom control which includes a currentValue property. I defined it in metadata as below:

properties: 
{
    currentValue: 
    {
        type: 'int',
        defaultValue: 0
    },...

in my Main.controller.js I'm calling the custom control that I created and changed it's currentValue property as below.

var oCustomControl = this.getView().byId("customID1");
oCustomControl.setCurrentValue(75);

in this step in my control.js, I didn't create a setCurrentValue function. Because I know UI5 is creating it itself. But the currentValue property of my control couldn't been updated. So I'm thinking my control couldn't been rerendered. So I overwrote the currentValue setter and change it as below:

setCurrentValue : function(iCurrentValue)
{
    this.setProperty("currentValue", iCurrentValue);
},

But still I couldn't see the value which I changed in my view.

Here is my renderer:

renderer : 
{

    render : function(oRm, oControl) {



        var layout = oControl.createGauges();//I created layout

        oRm.write("<div");
        oRm.writeControlData(layout);
        oRm.writeClasses(); 
        oRm.write(">");
        oRm.renderControl(layout);
        oRm.addClass('verticalAlignment');
        oRm.write("</div>");
    }
},

I am thinking now maybe it is because I'm rendering layout as a control?

and my other properties are related with d3.js. And I coded d3.js codes in my onAfterRendering function.

Upvotes: 0

Views: 174

Answers (2)

melomg
melomg

Reputation: 748

It is solved by changing

oRm.writeControlData(layout); this line as follow:

oRm.writeControlData(oControl);

Upvotes: 0

Arwed Mett
Arwed Mett

Reputation: 2749

Actually your code looks fine. Accept that you have specified:

bindable: 'bindable'

What should that do? And what does rerender()?

The method to render a control is called renderer().

But you don't need to call it when you say:

this.setProperty("currentValue", iCurrentValue);

If you dont say true it will rerender the control.

It would be nice to know whats inside your renderer() function, or what happens when you call getCurrentValue().

Upvotes: 1

Related Questions