Search code examples
data-bindingcustom-controlssapui5jsonmodel

Listener for the JSONModel for Custom Control UI5


i have a custom control which need to array of data as below

properties : {
            scrollheight: {type : "sap.ui.core.CSSSize", defaultValue : "100%"},
            array1 :{type : "Array", defaultValue : []},
            array2 : {type : "Array", defaultValue : []},
        }

and i have 3 JSONModel which i have set to the View

Problem is i need to process these model and i have to make 2 arrays to set to the Custom control.

When any change happen to these JSONModels i need to update the array also.

How can i achieve this, if i bind these to property? or do i need to listen the changes to the model and update the array?

or is their any other method of doing it?


Solution

  • i solved this by getting the binding and attaching change event

    We have to get the binding for particular item in the Model if its property we can take PropertyBinding if its List or array we have to take ListBinding

    and then i have one model which is set to the Custom Control and change event will update the Custom control model

    JSBin which shows how to add the change event to binding(Here i used ListBinding)