CIC92 CIC92 - 1 month ago 25
Javascript Question

how to add label inside expanded panel sapui5

Hi I have a dialog witch contains a panel that I should expand it and display a text / label or another controller with some text.
I managed to do the panel stuff but I don't know how to display the label inside the expanded panel.(I can't find any examples made in js without doing it in xml)

here is my code:

var panel = new sap.m.Panel("panel-1", {
/* justifyContent : sap.m.FlexJustifyContent.Center,*/
headerText:(oError.message),
width : '100%',
expandable: true
});
var dialog = new Dialog({
title: "There was an error while trying to resend the message",
contentWidth: "500px",
resizable: true,
type: 'Message',
state: 'Error',
/*content: new sap.m.Label({
id : 'labeldialog',
justifyContent : sap.m.FlexJustifyContent.Center,
text: JSON.parse(oError.response.body).error.message.value,
}),*/
content: [panel],

beginButton: new sap.m.Button({
text: 'Close',
press: function () {
dialog.close();
}
}),

afterClose: function() {
dialog.destroy();
}
});

dialog.open();


What should I use to achieve a control in such a way to put a string or a parameter in the collapsed part. thank you.

enter image description here

Answer

Did you try this?

var panel = new sap.m.Panel("panel-1", {
                headerText:(oError.message),
                width : '100%',
                expandable: true,
                content: [ new sap.m.Text("someId", { "Your message here" })]
            });