Code Monkey home page Code Monkey logo

vaibhavmojidra / sap-ui5---demo-json-model Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 35 KB

JSON Model in SAP UI5 is a client-side model and supports two-way data binding. It holds the data and provides methods to retrieve the data and to set and update data

Home Page: https://vaibhavmojidra.github.io/site/

License: MIT License

JavaScript 53.33% HTML 46.67%
fiori json model mojidra sap sap-ui5 ui5 vaibhav vaibhav-mojidra vaibhavmojidra

sap-ui5---demo-json-model's Introduction

SAP UI5 Demo JSON Model

JSON Model in SAP UI5 is a client-side model and supports two-way data binding. It holds the data and provides methods to retrieve the data and to set and update data.


Code Explaination:

Refer to /webapp/view/App.view.xml

<Input value="{/name}" description="Hello {/name}" valueLiveUpdate="true" width="30%"/>: This is an Input UI element. The value attribute binds the input's value to the /name path in the model. The description attribute sets a description that includes the input's current value. The valueLiveUpdate attribute enables live update for the input's value, meaning it updates as soon as you type. The width attribute sets the input's width to 30% of its container's width.

In this code, {/name} refers to the name property in the JSON model. When you change the value in the input field, it will automatically update the name property in the model because of two-way data binding. The description "Hello {/name}" will also update automatically to reflect the current value of name.

The curly brackets {โ€ฆ} indicate that data is taken from the value of the name property. This is called "data binding"

Refer to /webapp/controller/App.controller.js

onInit is one of SAPUI5โ€™s lifecycle methods that is invoked by the framework when the controller is created, similar to a constructor function of a control.

sap.ui.model.json.JSONModel: This is the JSON Model class from the SAP UI5 framework. A JSON Model is a client-side model and, as the name suggests, it supports JSON data.

var oData={name:"Vaibhav Mojidra"};: Here, a JavaScript object oData is being created with a single property name that has the value "Vaibhav Mojidra".

var oModel=new JSONModel(oData);: A new instance of the JSON Model is being created with oData as its data.

this.getView().setModel(oModel);: The model instance oModel is then set to the current view. This allows data binding between the view and the model in SAP UI5, meaning any UI elements in the view can now access and display the data from this model.


Vaibhav Mojidra - 1.jpeg

Vaibhav Mojidra - 2.jpeg

sap-ui5---demo-json-model's People

Contributors

vaibhavmojidra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.