PDA

View Full Version : Error Clarification



JoeWhitlock
25 Jan 2011, 1:29 PM
Can someone please tell me why I am getting or what causes this error?

Node cannot be inserted at the specified point in the hierarchy" code: "3

ext-all-debug.js (line 10978)


if(this.el){
this.el = Ext.get(this.el);
if(this.allowDomMove !== false){
ct.dom.insertBefore(this.el.dom, position); // line 10978
if (div) {
Ext.removeNode(div);
div = null;
}
}
}

25 Jan 2011, 1:44 PM
Can someone please tell me why I am getting or what causes this error?

Node cannot be inserted at the specified point in the hierarchy" code: "3

ext-all-debug.js (line 10978)


if(this.el){
this.el = Ext.get(this.el);
if(this.allowDomMove !== false){
ct.dom.insertBefore(this.el.dom, position); // line 10978
if (div) {
Ext.removeNode(div);
div = null;
}
}
}



That is inside of Ext.Component ( the class ). what is going on in your code when you get this error? It has to do w/ injecting dom elements.

JoeWhitlock
25 Jan 2011, 1:54 PM
I'm sure it has to do with my JSON. Here is my JS & PHP. Any help is appreciated.




Ext.BLANK_IMAGE_URL = 'resources/images/default/s.gif';

Ext.onReady(function(){

//create data store


var dataStore = new Ext.data.JsonStore({

url:'Products.php',

root:'products',

fields:['TITLE', 'IMAGE', 'INSTOCK', 'PRICE', 'CATEGORY', 'MANUFACTR']

});

//define the columns


var cm = new Ext.grid.ColumnModel([{

header:"Title",

dataIndex:"TITLE",

width:40,

},{

header:"Image",

dataIndex:"IMAGE",

width:40

},{

header:"In-Stock?",

dataIndex:"INSTOCK",

width:1

},{

header:"Price",

dataIndex:"PRICE",

width:10

},{

header:"Category",

dataIndex:"CATEGORY",

width:20

},{

header:"Manufacturer",

dataIndex:"MANUFACTR",

width:20

}]);

//define the grid


var grid = new Ext.grid.GridPanel({

el:"productGrid",

width:700,

height:500,

title:"Products",

store:dataStore,

cm:cm,

});

//render the grid


grid.render('productGrid');


//load the data


dataStore.load();

?
});




<?php

$server='localhost';
$username=''; // user id can be upper or lower case

$password='';
$conn = i5_connect($server,$username,$password);
if (!$conn){
die("Connection failed: Error Number: ".i5_errno()." Error Message: ".i5_errormsg());
}

if ($conn){
$result = i5_prepare("SELECT * FROM products");
i5_execute($result);

if ($result){
$products = array();

$row = i5_fetch_array($result);

// build json object with stuff from db


while ($row = i5_fetch_row($result)) {
$products[] = $row;
}

?
//output complete json object

echo '{"products":'.json_encode($products).'}';

}


} else{
die('myOpen failed to return a connection!');
}

if ($conn){
i5_close($conn);
}
?>

25 Jan 2011, 1:59 PM
do not specify el and then call .render() :)


try:




var grid = new Ext.grid.GridPanel({
renderTo: "productGrid",
width: 700,
height: 500,
title: "Products",
store: dataStore,
cm: cm, // <<--- Remove this extra comma too

});

25 Jan 2011, 1:59 PM
Also i would suggest using a PHP framework like Code igniter.

JoeWhitlock
25 Jan 2011, 2:33 PM
Thanks for the reply and fix. I did get my JSON back, now to work on why it did not display. I validated my returned JSON with the online validator. Perhaps later on the framework. I'm trying to understand what is happening with Ext JS first.

25 Jan 2011, 2:38 PM
Joe, if you want to learn Ext JS, try my book. Chapters 1 and 4 are free here: http://manning.com/garcia/