2 a824116228 a824116228 于 2016.04.10 04:03 提问

extjs遍历json集合问题

后台使用级联查询两个表数据,向前段输出一个json集合,前台应该如何接收该json集合,以及前台如何将json遍历出来?
附上json格式:{"datas":[{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":2,"month":3,"nanos":0,"seconds":31,"time":1460199751000,"timezoneOffset":-480,"year":116},"id":"402881e953fa67fe0153faaffeb30003","modifyDate":null,"state":false,"statu":1},{"cash":123,"consumerId":"402881e953ae826f0153ae82ddf10001","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":3,"month":3,"nanos":0,"seconds":53,"time":1460199833000,"timezoneOffset":-480,"year":116},"id":"402881e953fa67fe0153fab140a50004","modifyDate":null,"state":true,"statu":1},{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":5,"month":3,"nanos":0,"seconds":20,"time":1460199920000,"timezoneOffset":-480,"year":116},"id":"402881e953fa67fe0153fab295170005","modifyDate":null,"state":true,"statu":1},{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":7,"month":3,"nanos":0,"seconds":22,"time":1460200042000,"timezoneOffset":-480,"year":116},"id":"402881e953fa67fe0153fab471bd0006","modifyDate":null,"state":true,"statu":1},{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":8,"month":3,"nanos":0,"seconds":59,"time":1460200139000,"timezoneOffset":-480,"year":116},"id":"402881e953fab5660153fab5ebeb0000","modifyDate":null,"state":true,"statu":1},{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":10,"month":3,"nanos":0,"seconds":20,"time":1460200220000,"timezoneOffset":-480,"year":116},"id":"402881e953fab5660153fab727a40001","modifyDate":{"date":9,"day":6,"hours":19,"minutes":10,"month":3,"nanos":0,"seconds":20,"time":1460200220000,"timezoneOffset":-480,"year":116},"state":true,"statu":1},{"cash":100,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":11,"month":3,"nanos":0,"seconds":23,"time":1460200283000,"timezoneOffset":-480,"year":116},"id":"402881e953fab5660153fab81cac0002","modifyDate":{"date":9,"day":6,"hours":19,"minutes":11,"month":3,"nanos":0,"seconds":23,"time":1460200283000,"timezoneOffset":-480,"year":116},"state":true,"statu":1},{"cash":100,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":9,"day":6,"hours":19,"minutes":12,"month":3,"nanos":0,"seconds":30,"time":1460200350000,"timezoneOffset":-480,"year":116},"id":"402881e953fab5660153fab9224c0003","modifyDate":{"date":9,"day":6,"hours":19,"minutes":12,"month":3,"nanos":0,"seconds":30,"time":1460200350000,"timezoneOffset":-480,"year":116},"state":true,"statu":1},{"cash":50,"consumerId":"402881e953ae826f0153ae82ddf10001","consumers":[],"createDate":{"date":7,"day":4,"hours":14,"minutes":36,"month":3,"nanos":0,"seconds":41,"time":1460011001000,"timezoneOffset":-480,"year":116},"id":"402881f353ef64290153ef6fe8010000","modifyDate":{"date":9,"day":6,"hours":19,"minutes":1,"month":3,"nanos":0,"seconds":34,"time":1460199694000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":123,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":14,"minutes":39,"month":3,"nanos":0,"seconds":53,"time":1460011193000,"timezoneOffset":-480,"year":116},"id":"402881f353ef64290153ef72d4be0001","modifyDate":{"date":8,"day":5,"hours":9,"minutes":38,"month":3,"nanos":0,"seconds":59,"time":1460079539000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":123,"consumerId":"402881e953ae826f0153ae82ddf10001","consumers":[],"createDate":{"date":7,"day":4,"hours":18,"minutes":25,"month":3,"nanos":0,"seconds":12,"time":1460024712000,"timezoneOffset":-480,"year":116},"id":"402881f353f02eaa0153f0411e0c0000","modifyDate":{"date":8,"day":5,"hours":18,"minutes":25,"month":3,"nanos":0,"seconds":12,"time":1460111112000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":31,"month":3,"nanos":0,"seconds":47,"time":1460032307000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b502e90000","modifyDate":{"date":8,"day":5,"hours":20,"minutes":39,"month":3,"nanos":0,"seconds":14,"time":1460119154000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":33,"month":3,"nanos":0,"seconds":6,"time":1460032386000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6344d0001","modifyDate":{"date":8,"day":5,"hours":20,"minutes":39,"month":3,"nanos":0,"seconds":24,"time":1460119164000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":33,"month":3,"nanos":0,"seconds":17,"time":1460032397000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b65f3a0002","modifyDate":{"date":7,"day":4,"hours":9,"minutes":51,"month":3,"nanos":0,"seconds":34,"time":1459993894000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":33,"month":3,"nanos":0,"seconds":49,"time":1460032429000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0003","modifyDate":{"date":7,"day":4,"hours":20,"minutes":33,"month":3,"nanos":0,"seconds":49,"time":1460032429000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":34,"month":3,"nanos":0,"seconds":39,"time":1460032479000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0004","modifyDate":{"date":9,"day":6,"hours":19,"minutes":0,"month":3,"nanos":0,"seconds":43,"time":1460199643000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":34,"month":3,"nanos":0,"seconds":55,"time":1460032495000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0005","modifyDate":{"date":9,"day":6,"hours":19,"minutes":0,"month":3,"nanos":0,"seconds":40,"time":1460199640000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":35,"month":3,"nanos":0,"seconds":22,"time":1460032522000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0006","modifyDate":{"date":8,"day":5,"hours":12,"minutes":18,"month":3,"nanos":0,"seconds":35,"time":1460089115000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":35,"month":3,"nanos":0,"seconds":51,"time":1460032551000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0007","modifyDate":{"date":8,"day":5,"hours":10,"minutes":12,"month":3,"nanos":0,"seconds":35,"time":1460081555000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":36,"month":3,"nanos":0,"seconds":18,"time":1460032578000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0008","modifyDate":{"date":8,"day":5,"hours":10,"minutes":7,"month":3,"nanos":0,"seconds":45,"time":1460081265000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":36,"month":3,"nanos":0,"seconds":37,"time":1460032597000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0009","modifyDate":{"date":8,"day":5,"hours":10,"minutes":7,"month":3,"nanos":0,"seconds":43,"time":1460081263000,"timezoneOffset":-480,"year":116},"state":true,"statu":3},{"cash":50,"consumerId":"402881f353e4650e0153e544f6ce0004","consumers":[],"createDate":{"date":7,"day":4,"hours":20,"minutes":36,"month":3,"nanos":0,"seconds":55,"time":1460032615000,"timezoneOffset":-480,"year":116},"id":"402881f353f071b30153f0b6dfaf0010","modifyDate":{"date":9,"day":6,"hours":19,"minutes":1,"month":3,"nanos":0,"seconds":28,"time":1460199688000,"timezoneOffset":-480,"year":116},"state":true,"statu":3}],"pageCount":1,"pageIndex":1,"total":22}

3个回答

showbo
showbo   Ds   Rxr 2016.08.07 12:09

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.Ajax-method-request

Ext.Ajax.request请求地址获取返回值,用Ext.decode转为json对象,遍历就是按照数组遍历那样就行了,这个是js基础。不会自己多学点js基础了

fubo1990
fubo1990   2016.04.11 09:32

extjs中也是可以使用Jquery的。你jquery如果遍历一个json格式数据,extjs同样可以使用。

CSDNXIAOD
CSDNXIAOD   2016.04.10 04:11

安卓开发----关于集合遍历的问题
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!