首页 > 解决方案 > Why doesn't the json model's odata property have columns?

问题描述

I am creating a JSON model in UI5 from a json object. But it is missing the columns array in the JSON model. I checked the model in the console and the odata property had no columns. Check image for proof.

https://ibb.co/hLmYpZb

Hence I want to know how I can get the column to show up.

Here is my code.

var emptyModel = {
    "columns": []
};
this.setModel(new JSONModel(JSON.stringify(emptyModel)), "selcontent");

I expect column to show up in the JSON model under the odata property.

标签: jsonsapui5

解决方案


JSONModel awaits a plain object or a URL string as the first argument.

Either the URL where to load the JSON from or a JS object (source)

The result of the stringified emptyModel is "{"columns":[]}" which is neither an object nor a URL.


推荐阅读