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条)

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错