cancel
Showing results for 
Search instead for 
Did you mean: 

layoutData in XML View doesn't work with derived control

frankluzat
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

frankluzat
Participant

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>

karthikarjun
Active Contributor
0 Kudos

Great ... Could you please mark your answer as correct.

And close this thread.

Thanks,

Karthik A

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos
frankluzat
Participant
0 Kudos

Hi Karthik,

sorry, I think you didn't get my problem.

My problem is related to using layoutData for my custom control which leads to an error message.