PDA

View Full Version : Problem with JSONP, SOLR and saving to store



jdice19
1 Nov 2013, 7:29 AM
I am having problems with JSONP, SOLR and saving the returned results to the store.

Code Snippets

this.store = new Ext.data.JsonStore({
storeId: 'smtiExplorerInbox',
idProperty: "MyInWorkFolder",
fields: [{name: 'docs', type: 'auto'}],
successProperty: 'success',
proxy: new Ext.data.ScriptTagProxy({
type: 'jsonp',
url: 'http://server.com/solr//select?q=*%3A*&wt=json&indent=true&json.wrf=stcCallback1001'
}),
reader: new Ext.data.JsonReader({
type: 'json',
totalProperty: 'total',
root: 'response'
})
});

grid.store.load({
stcCallback1001: function (records, options, success) {
console.log("HERE");
}

JSON response

stcCallback1001({
"responseHeader": {*some stuff*},
"response": {"docs": [*stuff I want*]}
})


My questions are
1) The callback function never seems to be called. The console never logs and when I debug using firebug I get no errors. Why is that?
2) The saving of the response to the store never happens. I see the response in firebug, but the store is always of length 0.

If I'm making any bad assumptions (just started learning Ext) please let me know.

Thanks

jdice19
1 Nov 2013, 10:23 AM
For the saving of the JSON from the server, does there need to be a seperate save function or method invoked somewhere?

Sample JSON response

{
"responseHeader": {

"status": 0,
"params" : {}

},
"response": {

"docs": [

"item1": [*items*],
"item2": [*items*],
...
"itemn": [*items*]

]

}
}

Say I want to only save the docs portion of the JSON response. In the root can I specify "docs" as my array of JSON records to be saved? And does it automatically convert them?

slemmon
4 Nov 2013, 2:56 PM
If your server response is passing back a callback of anything other than 'callback' make sure you set the callbackParam on the proxy:
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.ScriptTagProxy-cfg-callbackParam

Not sure I follow the question about saving the JSON in the server response. Are you just wanting the server's response to populate the store with records?