Ext.data.JsonReader - pass Json directly - Ext JS

讨论了ExtJS中JsonReader组件的使用方法,提出了直接传递JSON文本到readRecords方法以提高灵活性的建议,并得到了官方团队的支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

First, i LOVE the JsonReader in the Data class! Awesome work, this is going to make things much easier to build. Nice work!

One suggestion:

In JsonReader.js, I notice that you can only pass a response:

Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
    read : function(response){
        var json = response.responseText;
        var o = eval("("+json+")");
        if(!o) {
            throw {message: "JsonReader.read: Json object not found"};
        }
        return this.readRecords(o);
    },
Is there a way you can also pass Json text?
I ask because I use another AJAX provider that can return Json already, and I would like to get that returned Json string and just pass it directly to the JsonReader. In my scenario, I have already handled the response.responseText, and I already have the Json located in a string. I'd like to be able to call the JsonReader and just pass the Json string.

Possible for a future release?

Thanks!

-- W.G.
Reply With Quote
  #2  
Old 03-08-2007, 01:38 PM
Default

I assume that means you're not going thru the proxy classes, so you could just eval your json string into an object and pas that to readRecords() instead of calling read()
__________________
Tim Ryan - Ext JS Support Team
Read BEFORE posting a question / posting a Bug
Use Google to Search - API / Forum
API Doc (3.x | 2.x | 1.x) / FAQ / Wiki / Tutorials / 1.x->2.0 Migration Guide
Reply With Quote
  #3  
Old 03-08-2007, 01:46 PM
Default

By George, that's true.. I could just eval my returned Json and pass to readRecords.

I love this forum, everyone is so enthused and offers such great insight. I've learned more about JavaScript in the last two months than I have in the last 4 years.

Thank you!

-- W.G.
Reply With Quote
  #4  
Old 03-08-2007, 05:41 PM
Default

Also, if it's going into a Store, you can eval the response and pass it to store.loadData(obj) and everythng in the store will get updated appropriately.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值