0

I am calling a rest webscript using Extjs with JSON,but unable to display on view. The problem is i am getting the json data as response from the server.But when i want to display on view.Its not getting displayed.

here is my json:

{
"data":
{
    "ticket":"TICKET_87c91dd9d18d7242e44ff638df01e0cb388ee4c7"
}
}

and here is extjs code:

Ext.onReady(function() {

alert("in login js");

var store = new Ext.data.JsonStore({
    proxy : new Ext.data.ScriptTagProxy({

        // url : 'http://ip:8080/alfresco/service/api/login',
        url : 'http://ip:8080/alfresco/service/api/login?u=Value1&pw=Value2&format=json',
        method : 'GET'


    }),

     reader : new Ext.data.JsonReader({ 
                root : 'data', 
                fields : ['ticket']
     })


});

alert("after the webscript call");
//store.load();
 var grid = new Ext.grid.GridPanel({
    renderTo: 'PagingFragment',
    frame:true,
    width:600,
    height:800,
    autoHeight: true,
    autoWidth: true,
    store: store,
    loadMask:true,
    columns: [
    {
        height:100,
        width:100,
        header: "Ticket",
        dataIndex: 'ticket',
       // renderer: title_img,
        //id: 'ticket',
        sortable: true
    }

    ],

    bbar: new Ext.PagingToolbar({
        pageSize: 2,
        store:store,
        displayInfo: true,
        displayMsg: 'Displaying topics {0} - {1} of {2}'

    }),
    sm: new Ext.grid.RowSelectionModel({
        singleSelect: true,
        listeners: {
            rowselect: {
                fn: function(sm,index,record) {
                    Ext.Msg.alert('You Selected',record.data.title);
                }
            }
        }
    })
});
store.load({
    params: {
        start: 0,
        limit: 5
    }
});

});

and in jsp:

<body>
    <div id="PagingFragment" style="position:absolute;top:10px;left:200px">

    </div>


</body>

could anybody help on this

maanoor99
  • 131
  • 2
  • 4
  • 15

1 Answers1

0

'data' must be an array. Instead of { data: { ticket: 'blahblahblah' } } you must return { data: [{ ticket: 'blahblahblah' }] } see the diference?

  • Thanks,but when i check the json here[link](http://jsonlint.com/).It is saying valid.Is this array concept is applicable to ExtJS only? – maanoor99 Feb 29 '12 at 16:53
  • The json is well formed but it's not what the reader expects to find. See the samples. Scan the requests/responses of any grid samples that uses remote data and you'll get a sample of the data you need to return to the reader. – Diego L Espiñeira May 03 '12 at 12:30