View Full Version : Viewport adding grid to container problem

26 Oct 2011, 2:04 AM
I am newbie with extjs4.

I am using mvc with autoCreateViewport: true,

In the View port i have on west a tree (menu) and on center a container.
When i try to load a grid to panel, for the fist time everything goes fine, but second time i get following error:

Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLDivElement.insertBefore]

target.insertBefore(item.el.dom, position || null);

If try to load simple panel everything works fine

Ext.define('AM.view.Viewport', {
extend: 'Ext.container.Viewport',

layout : 'border',

requires: [


initComponent: function() {
var me = this;

me.items = [
xtype: 'box',
id: 'header',
region: 'north',
html: '<h1>Portal 2.0</h1>',
height: 30


border: false,
margins: '0 0 0 0',
width: 275,
minWidth: 150,
maxWidth: 400,
xtype: 'treepanel',
title: 'Menu',
rootVisible: false,
autoScroll: true,
collapsible: true,
animate: true,
useArrows: true,
itemId: 'treePanelPrincipal',
dockedItems: [{
xtype: 'toolbar',
items: [{
text: 'Expandir todos',
iconCls: 'expand',
handler: function(){
}, {
text: 'Contrair todos',
iconCls: 'collapse',
handler: function(){
listeners: {
itemclick: function(view, record, item, index, evt, options) {
if (record.get('leaf')) {
title: record.get('text') || 'Tela do sistema',
autoDestroy: true,
items: {
xtype: record.raw['xtypeClass']

store: Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'menu.php',
noCache : false,
actionMethods: {
read: 'POST'

xtype: 'container',
region: 'center',
border: false,
id: 'Centro',
layout: 'fit',
items:[{ xtype: 'paineldeteste'}]



thanks !

26 Oct 2011, 2:31 AM
Please use CODE tags when posting code (# button on the editor toolbar).

That sample is a little on the long side and there are key dependencies missing. Are you able to extract a simple, complete test case? Try to reduce the code down, trim out any config settings and components that aren't required. For example, could you remove the toolbar? Often the process of reducing down the code identifies the problem. If possible also try to remove the external dependencies such as the Ajax call, that makes it very difficult for us to figure out what's going on. Such calls can usually be replaced with a small amount of local, hard-coded data. I also don't see the code for the grid you mentioned. I suspect the problem may actually be in the grid definition.