var store = Ext.create('Ext.data.Store', {
model:'Task',
proxy : new Ext.data.HttpProxy({
url : 'detail_qurey.asp?projectid='+projectid, //说明后台的serverlet
method : 'POST'
}),
reader : new Ext.data.JsonReader({
root : "rows",
totalProperty : 'total',
id: 'itemid'
},Task), //说明数据结构sortInfo : {property: 'itemid', direction: 'ASC'},
groupField: 'bigitem'
});
store.load({
scope : store ,
callback: function(records, operation, success) {
if (success) {
alert(records.length);
}
}
});
我不知道为什么不显示数据,alert(records.length)为1,在firebug里面查看json是有的啊
{"rows":[{"itemid":1,"itemname":"\u5730\u9762","bigitem":"\u53A8\u623F","unitprice":"20","unit":null,"size":"100","price":null,"content":null}],"total":1}
但是 alert(records[0].get('itemname'));为空 。始终没数据显示的,哪位哥有经验求教啊,谢谢了,分不多
model:'Task',
proxy : new Ext.data.HttpProxy({
url : 'detail_qurey.asp?projectid='+projectid, //说明后台的serverlet
method : 'POST'
}),
reader : new Ext.data.JsonReader({
root : "rows",
totalProperty : 'total',
id: 'itemid'
},Task), //说明数据结构sortInfo : {property: 'itemid', direction: 'ASC'},
groupField: 'bigitem'
});
store.load({
scope : store ,
callback: function(records, operation, success) {
if (success) {
alert(records.length);
}
}
});
我不知道为什么不显示数据,alert(records.length)为1,在firebug里面查看json是有的啊
{"rows":[{"itemid":1,"itemname":"\u5730\u9762","bigitem":"\u53A8\u623F","unitprice":"20","unit":null,"size":"100","price":null,"content":null}],"total":1}
但是 alert(records[0].get('itemname'));为空 。始终没数据显示的,哪位哥有经验求教啊,谢谢了,分不多
解决方案 »
- jquery 给span赋值问题
- ajax +actipn 无法回调值 求帮助
- 如何实现这个功能
- 使用JavaScript操作网页元素 vml
- 在prototype.js中,关于$()方法传入的参数的问题,高手进来看看!
- 如何做html中的object标签中的东西
- 怎样把onclick事件中转移成oncontextmenu事件?即单击出现右键菜单。
- 怎样实现像OICQ那样能在任务栏里有个图标,并且在需要的时候该图标还会闪的。。。
- 如何让鼠标移到图片上时把鼠标的变成手指
- 如何在一个js文件中引用另一个js文件中定义的函数?先谢!
- 关于javascript外部链接
- 我又来送分了 关于标签下查询自标签的问题
Ext.define('Task', {
extend: 'Ext.data.Model',
idProperty: 'itemid',
fields: [
{name: 'itemid', type: 'int'},
{name: 'itemname', type: 'string'},
{name: 'bigitem', type: 'string'},
{name: 'unitprice', type: 'float'},
{name: 'unit', type: 'string'},
{name: 'size', type: 'float'},
{name: 'price', type: 'float'},
{name: 'content', type: 'string'}
]
});
if (success) {
if(store.getCount() != 0){
var sitemid = store.getAt(0).get('itemid');
var sitemname = store.getAt(0).get('itemname');
var sbigitem = store.getAt(0).get('bigitem');
...
}
}LZ换成这个试试...
proxy : new Ext.data.HttpProxy({
url : 'detail_qurey.asp?projectid='+projectid, //说明后台的serverlet
method : 'POST',
reader : new Ext.data.JsonReader({
root : "rows",
totalProperty : 'total',
id: 'itemid'
},Task) //说明数据结构}),
数据就出来了,不过新问题出来了,我的目的是把新增的记录批量保存到数据库,getNewRecords()是获取新增记录,代码如下
text: '保存记录',
handler : function(){
var inserted=store.getNewRecords() ; var updated=store.getUpdatedRecords() ;
var deleted=store.getRemovedRecords() ;
Ext.Ajax.request({
url: '11.asp',
method:'POST',
params: {
projectid: projectid,
inserted:inserted, updated:updated,
deleted:deleted
},
success: function(response, opts) {
alert(response.responseText)
},可是发现inserted[0].get("itemname")有正确数据而inserted返回的是[object,Object],服务器端接受处理数据出错,我无法确认inserted是json字符串还是什么,我估计是inserted数据格式有问题导致后台出错,各位有知道的么,谢谢