cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read property 'document' of null datajs.js

0 Kudos

Hi,

I'm receiving an error and i'm trying to find its cause.

In this scenario i'm creating a JS view and inside the createContent function i'm creating some ui controls and an OData model.

my suspicion is that when i use the setModel, the call the the OData service is triggered before the control get a chance to render, but thats just a suspicion.

i've attached the error and the stack trace.

Help would be very appreciated.

Many Thanks,


Rafi


  1. Uncaught TypeError: Cannot read property 'document' of null datajs.js:859




TypeError: Cannot read property 'document' of null at

Object.domById (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~201312101153~/sap-ui-core....) at sap.ui.core.Element.getDomRef (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~201312101153~/sap-ui-core....)

at sap.ui.commons.ComboBox.invalidate (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~2…153~/sap/ui/commons/libr...)

at sap.ui.core.Control.invalidate (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~201312101153~/sap-ui-core....)

at sap.ui.base.ManagedObject.destroyAggregation (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~201312101153~/sap-ui-core....)

at sap.ui.commons.ListBox.destroyItems (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~2…1153~/sap/ui/commons/lib...)

at sap.ui.commons.ComboBox.destroyItems (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~2…153~/sap/ui/commons/libr...)

at sap.ui.commons.DropdownBox.destroyItems (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~2…~/sap/ui/commons/library...)

at sap.ui.base.ManagedObject.updateAggregation (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~201312101153~/sap-ui-core....)

at sap.ui.commons.ComboBox.updateItems (https://cloudnwcportal-danoneb2bdev.hana.ondemand.com/ui5-dist/resources/~2…1153~/sap/ui/commons/lib...)

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

any idea?

former_member184867
Active Contributor
0 Kudos

Can you share the snippet ?

0 Kudos

its a bit complex because the code is splitted around many files (and i dont have access to all of it)

but basiscally its something like this:

var cell12 = new sap.ui.commons.layout.MatrixLayoutCell({

  colSpan : 1

  });

  var lblChannel = new sap.ui.commons.Label("lblChannel");

  lblChannel.setText(sharedData.getLocalizedText("cust_search.distchan.lbl"));

  lblChannel.setDesign(sap.ui.commons.LabelDesign.Bold);

  cell11.addContent(lblChannel);

  var ddbChannel = new sap.ui.commons.DropdownBox("ddbChannel");

  ddbChannel.setModel(sharedData.getCustomerSearchModel());

  var oItemTemplate = new sap.ui.core.ListItem();

  oItemTemplate.bindProperty("key", "Distrchn");

  oItemTemplate.bindProperty("text", "DistrchnT", function(fValue) {

  return this.getProperty("key") + " " + fValue;

  });

  ddbChannel.bindItems("/DistChannelCollection", oItemTemplate, null, [ new sap.ui.model.Filter("Salesorg", sap.ui.model.FilterOperator.EQ, gadgets.sappopup

  .getParameters(context)[0].salesOrganization.getParameter("Salesorg")) ]);

sharedData.getCustomerSearchModel() does:

var x = new sap.ui.model.odata.ODataModel(sServiceUrl, dataTypeJson);

  x.setCountSupported(false);

return  x