Skip to Content

layoutData in XML View doesn't work with derived control

Hi,

I have derived from sap.m.input to make the "Press enter key" available as public event:

sap.ui.define([ "sap/m/Input" ], function(Input) {
  "use strict";


  /**
   * This derivation of sap.m.Input is used to make the internal onsapenter event available in the public interface so
   * that e.g. a search can be triggered by the application when the users hits enter in one of the search form input
   * controls
   */
  var InputEx = sap.m.Input.extend('myapp.util.controls.InputEx', {
    metadata : {
      properties : {},
      aggregations : {},
      events : {
        enter : {
          parameters : {}
        }
      }
    },


    renderer : {},


  });


  InputEx.prototype.onsapenter = function() {
    if (Input.prototype.onsapenter) {
      // Call the base class implementation!!!
      Input.prototype.onsapenter.apply(this, arguments);
    }


    this.fireEnter();
  };


  return InputEx;
});

In one place of my XML view I have replaced the sap.m.input with my InputEx control now:

<ex:InputEx
  id="Inp-Equnr"
  type="Number"
  enter="onEnterInputEqui">
  <layoutData>
    <layout:GridData span="L2 M2 S4" />
  </layoutData>
</ex:InputEx>

These are the namespace declarations in my view:

<mvc:View
  controllerName="myapp.controller.Masterdata"
  xmlns:core="sap.ui.core"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns:layout="sap.ui.layout"
  xmlns:form="sap.ui.layout.form"
  xmlns:ex="myapp.util.controls"
  xmlns="sap.m">

After doing this change from sap.m.input to my InputEx I get the following error message in the console when loading the view:

Uncaught Error: failed to load 'sap/m/layoutData.js' from resources/sap/m/layoutData.js: 404 - Not Found

Is there anything I have forgotten in the implementation of my derived control?

Why can't I use layoutData like I used it before?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 28, 2015 at 11:52 AM

    Meanwhile I found the solution - also on SCN:

    https://scn.sap.com/thread/3650322

    I have to use the same namespace for the layoutData as with the custom control:

    <ex:InputEx
      id="Inp-Equnr"
      type="Number"
      enter="onEnterInputEqui">
      <ex:layoutData>
        <layout:GridData span="L2 M2 S4" />
      </ex:layoutData>
    </ex:InputEx>
    
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2015 at 11:31 AM
    Add comment
    10|10000 characters needed characters exceeded