on 10-16-2015 8:11 AM
Hello expert,
While I'm developing my project I add a button which is calling a dialog screen but on first time its working perfect. But If I want to press the button one more time there is a error like this: "Uncaught Error: The object with ID pddepLayout1 was destroyed and cannot be used anymore."
Please help this situation.
Here is my all code :
var opddepButton1 = new sap.m.Button('opddepButton1',{text:'Ekle',
press:function(oEvent){
oDialog.setBindingContext(oEvent.oSource
.getBindingContext());
openDialog();
}
});
function openDialog() {
oDialog.destroyContent();
var opddepButton = new sap.m.Button('opddepButton',{text:'Ekle',press:function(){
var fname = sap.ui.getCore().byId('pdmalkod').getValue();
var lname = sap.ui.getCore().byId('pdparti').getValue();
var aname = sap.ui.getCore().byId('pdmiktar').getValue();
var bname = sap.ui.getCore().byId('pdolcbir').getValue();
var cname = sap.ui.getCore().byId('pdmasyer').getValue();
var dname = sap.ui.getCore().byId('pdnedekod').getValue();
mdData.clients.push({"id":fname,"parti":lname,"miktar":aname,"olcbirimi":bname,"masyeri":cname,"nedkodu":dname });
oModel.setData(mdData);
oDialog.close();
}
});
var labelidmalkod = new sap.m.Label('labelidmalkod',{text:'Malzeme Kodu:'
});
var pdmalkod = new sap.m.Input('pdmalkod',{
});
var labelidparti = new sap.m.Label('labelidparti',{text:'Parti:'
});
var pdparti = new sap.m.Input('pdparti',{
});
var labelidmiktar = new sap.m.Label('labelidmiktar',{text:'Miktar:'
});
var pdmiktar = new sap.m.Input('pdmiktar',{
});
var labelidolcbir = new sap.m.Label('labelidolcbir',{text:'Ölçü Birimi:'
});
var pdolcbir = new sap.m.Input('pdolcbir',{
});
var labelidmasyer = new sap.m.Label('labelidmasyer',{text:'Masraf Yeri:'
});
var pdmasyer = new sap.m.Input('pdmasyer',{
});
var labelidnedkod = new sap.m.Label('labelidnedkod',{text:'Neden Kodu:'
});
var pdnedekod = new sap.m.Input('pdnedekod',{
});
pddepLayout1.createRow(labelidmalkod, pdmalkod);
pddepLayout1.createRow(labelidparti, pdparti);
pddepLayout1.createRow(labelidmiktar, pdmiktar);
pddepLayout1.createRow(labelidolcbir, pdolcbir);
pddepLayout1.createRow(labelidmasyer, pdmasyer);
pddepLayout1.createRow(labelidnedkod, pdnedekod);
pddepLayout1.createRow(opddepButton);
oDialog.addContent(pddepLayout1);
oDialog.open();
};
Thanks,
Ogulcan G.
Hi Ogulcan,
I guess pddepLayout1 is a Matrix Layout. You are adding this layout to a dialog content.
Instead of destroying content, why don't you use .removeAllRows() method of Matrix Layout. Something like this -
function openDialog() {
var oLayout = sap.ui.getCore().byId("pddepLayout1"); //Get Hold of Matrix Layout
oLayout.removeAllRows(); //Remove all Rows of Matrix Layout
//and then your code
}
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ogulcan,
Where are you creating the Matrix Layout with id 'pddepLayout1' ? Also can you try something like this as well?
function openDialog() {
var oLayout = sap.ui.getCore().byId("pddepLayout1"); //Matrix Layout
if(oLayout){ //If Matrix Layout with id pddepLayout1 exists
oLayout.removeAllRows(); //Remove Rows
}
//and then your code
}
Yes, there is a method .removeAllRows(). Here is the API: JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.commons.layout.MatrixLa...
Regards,
Sai Vellanki.
Hi Sai,
Do I need delete this code also on the beginning which creating pddepLayout1?
createContent : function(oController) {
"mobiletestproject.pddepgel202".viewName = "wwwwwwwwwwwww";
var pddepLayout = new sap.ui.commons.layout.MatrixLayout('pddepLayout');
pddepLayout.setWidth('100%');
var pddepLayout1 = new sap.ui.commons.layout.MatrixLayout('pddepLayout1');
pddepLayout1.setWidth('100%');
Ogulcan,
Check this sample, which is bit similar to your requirement: Plunker
Click on Edit, you will get the details of row and when you're closing the dialog, it just says sap.ui.getCore().byId("yourDialogID").destroy();
Regards,
Sai Vellanki.
Hi Ogulcan,
I think it´s because you "destroy the content" (line 12 in your code snippet) of the dialog when open it. At first time pddepLayout1 is not part of the content. So it works. After first call pddepLayout1 is part of the content as you added it in line 89. So it will be destroyed and afterwards you can´t use it anymore. So I don´t know what´s the best approach in your case but maybe you should consider only destroying the content of pddepLayout1 and not the content of the complete dialog.
Best regards,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.