cancel
Showing results for 
Search instead for 
Did you mean: 

how to bind json data to fragment?

0 Kudos

hello experts

in my project i have a table binded to json model.

my table has a column that contains a button that shows a fragment.

i need to bind the row data to the fragment.

this is my fragment.xml :

<ResponsivePopover title="{i18n>DesignDescr}">
	<content>
<richtexteditor:RichTextEditor id="RichDescription" value="{oJSONModel>/Description}"/>
	</content>
</ResponsivePopover>

this is my controller

onRichText: function (oEvent) {
	var oButton = oEvent.getSource();
	var sPathToBind;
if (!this._oPopover) {
this._oPopover = sap.ui.xmlfragment("fragmentId", "Table.view.RichText", this);
sPathToBind = oEvent.getSource().getBindingContext("oJSONModel").getPath();	
        this._oPopover.bindElement(sPathToBind);
	this.getView().addDependent(this._oPopover);		
	this._oPopover.openBy(oButton);

} else {
sPathToBind = oEvent.getSource().getBindingContext("oModelMNA").getPath();
	this._oPopover.bindElement(sPathToBind);
	this.getView().addDependent(this._oPopover);
	this._oPopover.openBy(oButton);
}

this is the result

i need to show tha value that exsists in the input , in the rich text area

when i debug the sPathToBind is getting values like this "/0" which is the row of the table.

how can i bind data please ?

Best regards

Stay safe

Accepted Solutions (1)

Accepted Solutions (1)

prashil
Advisor
Advisor
0 Kudos

Hi abdallah,

I think you need to modify you setBindingContext statement to:

this._oPopover.setBindingContext(oContext, "oJSONModel");

Answers (2)

Answers (2)

junwu
Active Contributor

	this.getView().addDependent(this._oPopover);

this._oPopover.setBindingContext(oEvent.getSource().getBindingContext("oModelMNA"));
<ResponsivePopover title="{i18n>DesignDescr}"><content><richtexteditor:RichTextEditor id="RichDescription" value="{oJSONModel>Description}"/></content></ResponsivePopover>
0 Kudos

thank for your response

theses are the modifications that i did :

controller :

if (!this._oPopover) {
this._oPopover = sap.ui.xmlfragment("fragmentId", "smartTable.SmartTable.view.RichText", this);
	this.getView().addDependent(this._oPopover);
	sPathToBind = oEvent.getSource().getBindingContext("oJSONModel").getPath();
			
       sap.ui.core.Fragment.byId("fragmentId","RichDescription").bindElement(sPathToBind);
       this._oPopover.openBy(oButton);

} else {
	this.getView().addDependent(this._oPopover);
	sPathToBind = oEvent.getSource().getBindingContext("oJSONModel").getPath();
	this._oPopover.bindElement(sPathToBind);
	this._oPopover.openBy(oButton);
			}


fragment :

<ResponsivePopover title="{i18n>DesignDescr}">

<content>

<richtexteditor:RichTextEditor id="RichDescription" value="{oJSONModel>Description}"/>

</content>

</ResponsivePopover>

but it still not working

data is not showing in the richtext editor

thank youu

junwu
Active Contributor
0 Kudos

check my code..... you are not following correctly.....

0 Kudos

hello

it is still not working

here is the code

onRichText: function (oEvent) {
	var oButton = oEvent.getSource();
	if (!this._oPopover) {
	this._oPopover = sap.ui.xmlfragment("fragmentId", "smartTable.SmartTable.view.RichText", this);
	this.getView().addDependent(this._oPopover);
        var oContext = oEvent.getSource().getBindingContext("oJSONModel");
	this._oPopover.setBindingContext(oContext);
			}
			this._oPopover.openBy(oButton);
},

thank youu

0 Kudos

Hi ,

Did you found solution on this ? I'm facing same issue that I'm unable to bind table record to the fragment .

If you have resolve this issue please share the solution .

Regards,