PDA

View Full Version : Loading empty grid (Python/Django)



NvidiaUser
12 Oct 2010, 12:14 PM
Hello everyone!!! I'm programming on Python and I have a problem : the grid load's, but it's empty. I've already wrote my own valid JSON , because Django serilized my objects incorrect. Here's my source code and Json string. Please help me, it's important for me to do that. Thanks for replying.

There is source code

Ext.onReady(function(){

var fields = [
{
name : 'cityName',
mapping : 'cityname'
}
];

var proxy = new Ext.data.HttpProxy({
url : 'http://127.0.0.1:8000/gridjsonremote'

});

var qwerty = Ext.data.Record.create([
{ name : 'cityname'}
]);

var reader = new Ext.data.JsonReader({
idProperty : 'id',
root : 'data',
totalProperty :'total'
});

var Mystore = new Ext.data.Store({
proxy : proxy,
fields : fields,
reader : reader,
autoLoad : true,
listeners :{
load : function(obj , records){
Ext.each(records , function(rec){
console.info('Hi' + rec.get('cityName')) ;
});
}
}
});
var columns = [{

header : 'City Name',
dataIndex : 'cityName'
}];

var grid = new Ext.grid.GridPanel({

renderTo : Ext.getBody(),
height : 100,
weight : 100,
store : Mystore,
loadMask : true,
columns : columns,
viewConfig : {
forceFit : true
}
});



});

And JSON string

({"success": true, "totalCount" : 2 , "data" : [ { "id" : 1 , "cityname" : "Lviv"}, { "id" : 2 , "cityname" : "Kyiv"}] });

Condor
13 Oct 2010, 3:01 AM
Please post using [CODE] tags and not with rediculously large fonts!

1. Use renderTo or render(), but not both.
2. JsonStore doesn't have a 'reader' config option. You want a normal 'Store'.
3. It's 'autoLoad' and not 'autoload'.
4. Also add an 'exception' event handler to the store and see if it fires.

NvidiaUser
18 Oct 2010, 9:39 AM
Thank you very much, because i thought that it's impossible to use Extjs on django and I've tried to do it more than a month.

I want to ask one more question: if i wrote JSON string myself and it's valid, will it work?

Condor
18 Oct 2010, 10:27 PM
1. You can use jslint.com to check if your JSON is valid.
2. Your totalProperty is wrong (it should be 'totalCount').
3. Change 'id' to 'idProperty' ('id' is deprecated).
4. This is NOT the correct response for a ScriptTagProxy. It is the correct response for a HttpProxy, but then the url would have to be on the same domain.

NvidiaUser
20 Oct 2010, 8:00 AM
My grid is still empty . I repost my source code in first message, and I don't know what's wrong.
url : 'http://127.0.0.1:8000/gridjsonremote' - this is the url to function that returns string
http://127.0.0.1:8000/admin/index/ - this is the url where my table is

same urls doesn't work.

NvidiaUser
13 Dec 2010, 2:23 AM
Why anybody doesn't reply to my thread????

I'm still don't know what's wrong with my tables...........

I received a message that "data is send", but I don't know why and where it's sand....

Condor
13 Dec 2010, 3:43 AM
'fields' is a config option of JsonReader and not of Store.