Extjs-Parsing JSON Data e display in vista
-
14-11-2019 - |
Domanda
Sto chiamando un riposo webscript utilizzando Extjs con JSON, ma non è in grado di visualizzare sulla vista. Il problema è che sto ottenendo i dati JSON come risposta dal server.BUT quando voglio visualizzare su Visualizza. << / P>
Ecco il mio JSON:
{
"data":
{
"ticket":"TICKET_87c91dd9d18d7242e44ff638df01e0cb388ee4c7"
}
}
.
Ed qui è il codice Extjs:
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
}
});
});
.
e in JSP:
<body>
<div id="PagingFragment" style="position:absolute;top:10px;left:200px">
</div>
</body>
.
Qualcuno potrebbe aiutare su questo
Soluzione
'Dati' deve essere un array. Invece di {Dati: {Biglietto: 'Blahblahblah'}} Devi tornare {Dati: [{Biglietto: 'Blahblahblah'}]} Vedi la differenza?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow