Skip to Content
author's profile photo Former Member
Former Member

Extending control getting problems.

Hi all,

i am extending an SAPUI5 control i am facing problem like creating dom elements multiple times,

the following code i am using.

sap.ui.commons.TextField.extend("HighlightField", {

metadata: {

properties : {name:{type:"string",defaultValue : "testingdefault"}

}

},

setName : function (ovalue){

this.setProperty("name",ovalue);

},

renderer: function(oRm, oControl){

//

sap.ui.commons.TextFieldRenderer.render(oRm,oControl); // any problem with this

oRm.write("<div");

oRm.writeControlData(oControl);

oRm.addStyle("display", "block");

oRm.writeStyles();

oRm.write(">");

oRm.write("<div id='testdiv'");

oRm.addStyle("display", "block");

oRm.writeStyles();

oRm.addClass("myClass");

oRm.writeClasses();

oRm.write(">Title : "+oControl.getName());

oRm.write("</div>");

oRm.write("</div>");

}

});

i am using this control by creating object and in other control even(like button click)

i am trying like follows,

onClick: function(evt){

obj.setName(Math.random()); // here i am getting object through parents this.getParent().getContent()[0]

obj.setValue(Math.random());

}

in this case of value its working fine , but in case of Name it's creating multiple names and appending(based on number of setName()'s)

Thanks & reagrds,

Kotesh Adabala

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2016 at 05:12 AM

    Problem solved by placing the line sap.ui.commons.TextFieldRenderer.render(oRm,oControl);

    after the div start like below

    oRm.write("<div");

    oRm.writeControlData(oControl);

    oRm.addStyle("display", "block");

    oRm.writeStyles();

    oRm.write(">");

    sap.ui.commons.TextFieldRenderer.render(oRm,oControl);


    and your html........




    Thanks & reagrds,

    Kotesh Adabala

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2016 at 05:33 AM

    Hi,

    if we overwrite the setter of one property it will effects total functinality

    setName : function (ovalue){

    this.setProperty("name",ovalue,true);

    },

    i am setting rendering false inf we setting name , but if i am setting setValue() it also not effecting in output like it's also stops rendering after value changing.

    what is reason behind it.


    Thanks & reagrds,

    Kotesh Adabala.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2016 at 05:57 AM

    Hi,

    as of my knowledge we need to overwrite every setter of properties and based on our requirement , just need to say whether this will effects to rendering or not like

    bSuppressInvalidate.



    setProperty('propertyname',value,true || false) //(true for stops re-render)


    Thanks & regards,

    Kotesh Adabala.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.