PDA

View Full Version : Dialog and gridpanel



galdaka
23 Jan 2007, 9:47 AM
Hi,

I have a dialog with center and east region. In center region I have three tabs that content one grid in each tab. If I use content panel no problem. If I use gridpanel the first click to "ShowDialog" works fine, but when close the dialog and click again in the "ShowDialog" button I have a error: "'disabled' is null or not is a object" => Line 326.

Thanks,

galdaka
26 Jan 2007, 4:44 AM
Hi,


var LayoutExample = function(){

var dialog, showBtn;

return {
init : function(){
showBtn = getEl('show-dialog-btn');
// attach to click event
showBtn.on('click', this.showDialog, this, true);

},

showDialog : function(){
if(!dialog){ // lazy initialize the dialog and only create it once
dialog = new YAHOO.ext.LayoutDialog("hello-dlg", {
modal:true,
width:600,
height:400,
shadow:true,
minWidth:300,
minHeight:300,
east: {
split:true,
initialSize: 150,
minSize: 150,
maxSize: 250,
titlebar: true
},
center: {
autoScroll:true,
tabPosition: 'top',
closeOnTab: true,
alwaysShowTabs: true
}
});
dialog.addKeyListener(27, dialog.hide, dialog);
dialog.addButton('Close', dialog.hide, dialog);
dialog.addButton('Submit', dialog.hide, dialog);


var cols = [{
header: "Login",
width: 75
},{
header: "Nombre",
width: 100
},{
header: "Apellido 1",
width: 100
},{
header: "Apellido 2",
width: 100
}];

colModel = new YAHOO.ext.grid.DefaultColumnModel(cols);
colModel.defaultSortable = true;

var schema = {
tagName: 'entry',
totalTag: 'totalDocs',
id: 'ID',
fields: ['cliente', 'cif', 'numAlbaran', 'numFactura']
};

dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
selectionModel = new YAHOO.ext.grid.EditorAndSelectionModel();
dataModel.baseParams = {'vista': "vista01"};
dataModel.initPaging('http://example, 13);

grid = new YAHOO.ext.grid.Grid('int', dataModel, colModel, selectionModel);
grid.render();

dataModel.loadPage(1);


var layout = dialog.getLayout();
dialog.beginUpdate();
layout.add('east', new YAHOO.ext.ContentPanel('east', {title: 'Usuarios seleccionados'}));
//THIS LINE FAILS - GRIDPANEL
layout.add('center', new YAHOO.ext.GridPanel(grid, {fitToFrame:true}));
//THIS LINE CORRECT - CONTENTPANEL
//layout.add('center', new YAHOO.ext.ContentPanel('int', {title: 'Internos'}));
layout.add('center', new YAHOO.ext.ContentPanel('ext', {title: 'Externos'}));
layout.add('center', new YAHOO.ext.ContentPanel('bec', {title: 'Becarios'}));
dialog.endUpdate();
layout.getRegion('center').getTabs().activate('int');
}
dialog.show(showBtn.dom);
}
};
}();

Why breaks my code when I use GridPanel?????

Animal
26 Jan 2007, 5:10 AM
A quick scan reveals the line



dataModel.initPaging('http://example, 13);


An unclosed quote. Is that a copy and paste error when you posted the code, or is that in your code?

But the way to debug is to run it in Firebug with "Break on all errors" checked. Make sure you use yui-ext-debug.js, so that you can se unminified code.

Then it breaks where the error is so you can see it. You can also trace back through the call stack to see where the call originated.

galdaka
28 Jan 2007, 10:47 AM
Thanks for your reply Animal,

The unclose quote error is a copy paste error (unfortunately). I would try debug with firebug. Thanks. IE error says: "'disabled' is null o not is a object in line 326".