Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

Simpleform Select element not renedered with an id

Hi


I am building an application and I need to list all form elements and enable and disable them from javascript.


The problem that i am having is that the Select element is getting rendered without an id, so I can't reference it from javascript e.g. sap.ui.getCore().byId(res[0]);  The div seems to get the name.




The following code is used to enable and disable the elements.  This is stored in a global javascript include that is shared between a lot of applications.

$('#MainForm :input').each(function() {

      if (this.id.indexOf('inMainForm') > -1){

        var res = this.id.split("-");

        if (res.length > 0){

          var theField = sap.ui.getCore().byId(res[0]);

          if (typeof theField != 'undefined') {

            theField.setEditable(iv_state);

          }

        }

      }

    });


Any ideas.

I can't bind the enabeld property, it has to be done from javascript.


Thanks


Darren

1 Comment

I was able to solve this by getting the parent node i.e. the div that the select is wrapped in.

  if (this.tagName == 'SELECT'){

    elemId = this.parentNode.id;

    if (elemId.indexOf('inMainForm') > -1){

       try{

         sap.ui.getCore().byId(elemId).setEnabled(false);

        }

        catch(error){

        }

    }


It is strange that the actual select element does not get an id.

Login or Signup to post a comment