xialadan 2009-03-19 09:48
浏览 210
已采纳

ext中查询后传给callback函数的数据到底是什么类型

比如使用HttpProxy的load函数举例,
其为load( Object params, Ext.data.DataReader reader, Function callback, Object scope, Object arg ) : void

callback : Function
The function into which to pass the block of Ext.data.Records. The function must be passed
The Record block object
The "arg" argument from the load function
A boolean success indicator

它说第一个参数为The Record block object,对象到底是什么,在哪里定义的。
因为我看别人可以通过这个参数得到返回的record集合,也可以直接得到记录数等,
但是ext里也没有Ext.data.Records这个对象啊。它到底是怎么定义的呢,在哪定义的。
[b]问题补充:[/b]
我觉得应该不是[{},{},{}]的格式吧,还是觉得它就是一个对象。
因为我在一本书上看到是这么用的,假设参数名为result;
那么得到record集合,可以使用var records=result.records,
而集合数,可以这样得到:var count=result.totalRecords;
[b]问题补充:[/b]
【【也就是说你从服务器端得到的数据,会经过reader的转化,变成一个对象,在reader里面定义的这些totalRecords这些属性,你就可以调用了。 】】

我并不觉得这是reader转化后的一个对象。
这应该是这个callback函数参数对象的直接属性。教材上所用例子也没有在reader中定义那些属性。
而且,你不可能去定义records这个属性吧,这是返回记录集,你怎么定义?

  • 写回答

6条回答 默认 最新

  • 马勒格彼得 2009-03-20 14:02
    关注

    返回的是个数组,你可以查看Store.js,在里面的说明中由于明确的文字描述

    • [color=red]callback[/color] : Function

      A function to be called after the Records have been loaded. The callback is

      • passed the following arguments:
          [color=red]*
        • r : Ext.data.Record[]
        • [/color]
      • options: Options object from the load call
    • success: Boolean success indicator
    scope : Object

    Scope with which to call the callback (defaults to the Store object)

    add : Boolean

    Indicator to append loaded records rather than replace the current cache.

    @return {Boolean} Whether the load fired (if beforeload failed). 而且在下面的loadRecords 的实现中表现的很明确,你可以看看 loadRecords : function(o, options, success){ if(!o || success === false){ if(success !== false){ this.fireEvent("load", this, [], options); } if(options.callback){ options.callback.call(options.scope || this, [], options, false); } return; } var r = o.records, t = o.totalRecords || r.length; if(!options || options.add !== true){ if(this.pruneModifiedRecords){ this.modified = []; } for(var i = 0, len = r.length; i < len; i++){ r[i].join(this); } if(this.snapshot){ this.data = this.snapshot; delete this.snapshot; } this.data.clear(); this.data.addAll(r); this.totalLength = t; this.applySort(); this.fireEvent("datachanged", this); }else{ this.totalLength = Math.max(t, this.data.length+r.length); this.add(r); } this.fireEvent("load", this, r, options); if(options.callback){ options.callback.call(options.scope || this, r, options, true); } },
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大