PDA

View Full Version : why JsonStore don't show responseText



edwardking
1 Jul 2010, 9:33 PM
I use response.responseText and want to show responseText into EditorGridPanel,my code is follows:


<script>
function sFn(response,options){
//response.responseText is {success:true,msg:'success,this time called 25 records'}
var responseData = Ext.util.JSON.decode(response.responseText);
var store=new Ext.data.JsonStore({
data:responseData,
fields:["success","msg"]
});
var colM=new Ext.grid.ColumnModel([{
header:"status",
dataIndex:"success"},
{header:"information",
dataIndex:"msg"}
]);
var grid = new Ext.grid.EditorGridPanel({
renderTo:"hello",
title:"test",
height:200,
width:600,
cm:colM,
store:store,
autoExpandColumn:0
});
}

function fFn(){
alert('fail');
}

Ext.Ajax.request({
url:'test.jsp?cmd=save' (http://'test.jsp/?cmd=save),
success:sFn,
failure: fFn,
params:{name:'Rose',email:'[email protected]',bornDate:'1992-5-6',sex:'M'}
});
</script>
<body>
<div id="hello"></div>
</body>


After run above code,it should show following result:
status??information
true ???success,this time called 25 records

but it only show following result:
status ??information

The responseText don't show! Why? How to correct above code?

Thanks in advance!

Condor
1 Jul 2010, 11:57 PM
JsonStore can only read an array of records.

data:[reponseData]