PDA

View Full Version : Unable to render Json data in a list



sachin sachdeva
29 Apr 2011, 2:54 AM
Hi i am using a very siple list but a i am unable to render my json data in it and goes in to a infinite loading state..my code is







Ext.ns("Test", "Test.stores");


Test = new Ext.Application({
defaultTarget : 'viewport',
name : 'test',
icon : 'icon.png',
glossOnIcon : false,
tabletStartupScreen : 'tablet_startup.png',
phoneStartupScreen : 'phone_startup.png',
launch : function() {
console.log('begin');

this.viewport = new Ext.Panel({
fullscreen : true,
dockedItems : [ {
title : 'Results',
xtype : 'toolbar',
ui : 'light',
dock : 'top'
} ],
layout : 'fit',
scroll : 'vertical',
items : [ {
xtype : 'list',
itemTpl : '<span id="{id}">{name}{type}</span>',
store : Test.stores.Properties,
singleSelect : true,
itemSelector : 'span.id',
onItemDisclosure : function(record, btn, index) {

}
} ],
flex : 1
});

}
});

Ext.regModel('Properties', {
fields : [ {
name : 'id',
type : 'string'
}, {
name : 'name',
type : 'string'
}
, {
name : 'type',
type : 'string'
}
]
});

Test.stores.Properties = new Ext.data.Store({
model : 'Properties',
proxy : {
type : 'scripttag',
url : 'wwwdev.XXX.com/ebook/admin.jsp',
reader : {
type : 'json',
root : 'ebooks',
totalCount : 'total'
}
},
autoLoad : true
});












MY json is
{"total":5, "ebooks":[{"id": "34", "name": "AMER","type":"ebook_admin"},{"id": "32", "name": "APAC","type":"ebook_admin"},{"id": "50", "name": "EMEA","type":"ebook_admin"},{"id": "37", "name": "File and Content","type":"ebook_admin"},{"id": "31", "name": "Healthcare","type":"ebook_admin"}]}





please let me know where i am mistakes i think its the simplest program that i have implemented.........

AndreaCammarata
29 Apr 2011, 2:18 PM
Hi sachin.

Does your application need to retrive data from a different domain?
I ask you because i see that you set your store proxy type as "scripttag".
Do you really need it?

If so, your php response is not well formatted.
Take a look at this sencha doc to know how to set your response data correclty.

http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.ScriptTagProxy

Hope this helps.

sachin sachdeva
29 Apr 2011, 11:19 PM
yes ...i do need noe i have done exactly the same thing but still no response neither sencha has provided any example of scripttag proxy....but or the time being let me show my server side code....



<%@page language="java" pageEncoding="UTF-8"%>
<%@page import="static com.ebook.common.Constants.*"%>
<%@page import="com.ebook.service.DocumentService"%>
<%
response.setContentType("application/json");
String documents = "";
documents = DocumentService.getEBooksJSON(_ADMIN_);
out.write(documents);
%>