PDA

View Full Version : Help Getting data From DB



thiago.andrade
17 Feb 2011, 12:12 PM
Hi Guys,
No need to say that im new using EXTJS (first post :D).
Im having issues getting this example: http://www.foscode.com/populate-extjs-mysql-datastore/ to work. I Did the PHP page (myDBConnection.php) and, if i run it alone on the page, i get this result from my DB table :
{"myInventory":[{"nome":"Joao Silva da Souza de Almeida"},{"nome":"Maria Alvarenga"},{"nome":"Silvia Santos"},{"nome":"Fernando Fernandes"},{"nome":"Joaquina de Abreu"}],"totalCount":5}
Is that correct?
Assumig it is a good-to-go result, i did the next step that was using this on the js file. It is like this:


Ext.onReady(function(){

var ds = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
url:'myDBConnection.php'
}),
reader: new Ext.data.JsonReader({
id: 'Completion_ID', // no need to change it right?
totalProperty: 'totalCount',
root: "myInventory",
fields:
[{name: 'name', type: 'string', mapping: 'name'}] //only getting the name to see if it works
})

});


var mycolModel = new Ext.grid.ColumnModel({
columns: [
{header: 'name', width:70, dataIndex: 'name'}
]
});

// trigger the data store load
ds.load({params:{start:0, limit:1000}});

//Now our grid
var grid = new Ext.grid.EditorGridPanel({
store: ds ,
stripeRows: true,
width: 630,
height:315,
autoSizeGrid: false,
title:'PM Status (Current Quarter)',
collapsible: false,
animCollapse: false
cm: mycolModel,
selModel: new Ext.grid.RowSelectionModel(),
viewConfig: {
forceFit: true
}

});
grid.render('grid-example');
};
Whats is wrong with this scenario? i just then insert this name on the div at the HTML and it does not get anything back.

Hoping you guys can help me.

Thanks!

arthurakay
18 Feb 2011, 12:52 PM
My initial thought is that your JSON result has a record property of "nome", and your grid's column model/store are looking for "name".

thiago.andrade
21 Feb 2011, 4:53 AM
Yeah... i figured that i needed a IDE to program.
I found lots of errors on the code and on the naming. One of them is the one that you pointed.
Im using Aptana to program now.

By the way, my Aptana is now showing php files correctly... it shows then just like a Notepad would.
Anyone have a guess why am able to see it formated?

Thanks guys!