View Full Version : ExtJS Store not able to display SOLR JSON string

23 Nov 2009, 1:27 PM
I am working with Apache SOLR search engine to display search results into an ExtJS Grid. SOLR supports a JSON result so I've mapped up just ID to start with to see if I could get that to work. Whenever I try to run this, I don't see the grid getting filled in. Any ideas?

Here's my JSON result from SOLR:


Heres is the ExtJS code:

var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'http://solrdev/solr/select/'
reader: new Ext.data.JsonReader({
id: 'id',
totalProperty: 'response.numFound',
root: 'response.docs'
}, Ext.data.Record.create([
baseParams: {q:'bird',version:'2.2',start:'0',rows:'10',indent:'on',qt:'dismax',wt:'json',"json.wrf":"strcallback1001"}

var grid = new Ext.grid.GridPanel({
store: ds,

columns: [
header: 'ID',
width: 120,
sortable: true,
dataIndex: 'id'
viewConfig: {
forceFit: false
renderTo: 'content',
title: 'SOLR Grid',
width: 500,
autoHeight: true,
frame: true


23 Nov 2009, 3:13 PM
I'm not real familiar with script tag proxy's, how is your function strcallback1001 getting called?

23 Nov 2009, 3:15 PM
do you need to add callbackParam: "strcallback1001" to your scriptTagProxy config?

23 Nov 2009, 4:15 PM
do you need to add callbackParam: "strcallback1001" to your scriptTagProxy config?

Yes, I've tried that as well. I've tried with and without the callback approach as well as moving the params up into the URL and that didn't work either.

23 Nov 2009, 6:24 PM
Actually, I had a typo. It should of been "stcCallback1001". That works when setting both in the params and the callback param. Thank you!

Fredric Berling
24 Nov 2009, 12:32 AM
It seems im doing the same as you are :).. This is my working code. You just specify callbackParam:'json.wrf' and Ext will tell SOlr whar the function should be called.

proxy: new Ext.data.ScriptTagProxy({
url: 'http://solr.mydomain.com:8080/solrdev/select/?',
method: 'GET',
baseParams: {
q: 'test',
sort:'subject asc',

24 Nov 2009, 10:03 PM
Thank you Fredric...that works much better for me. :)

I noticed that you have sort as part of your base params. This works fine for the initial pull but I've noticed that if I try to sort a column (using GroupingStore) it only sorts the rows on that page. I've read that you need to use "remoteSort:true" to get it to call the service again but it requires you to have two parameters (sort and dir). Unfortunately, SOLR sort of combines those in "sort". Have you found a way to manage sort with SOLR without writing some sort of wrapper?

Fredric Berling
24 Nov 2009, 11:55 PM
Hi locutusUT

Nice that im not the only one that uses solR. Well i havent come that far yet , but it will certantly be crucual for me to solve that issue too.

There must be a way to override that handling on remoteSort. If you beat me to the goal, please let me know.

Some more useful things regarding SolR and Ext JS together

*If you start using comboboxes with livesearch functions. Dont forget the queryParam: 'q' for changing the pameter name for "query"

*if you use pagination you must change parameter name for "limit" to "rows" using the paramNames: {limit:'rows'} on the store you are using