Tabular Data Control(TDC)实现Ajax简介

1 篇文章 0 订阅
首先简单介绍下TDC控件
Tabular Data Control
The Tabular Data Control (TDC) is a Microsoft ActiveX control that can be hosted by Internet Explorer to display data stored in a delimited text file.
TDC可以以object嵌入到页面,如下:

TDC可配置参数(File Properties)如下:
 CharSet:Identifies the character set used by the data file. The default character set is latin1.
 DataURL:Specifies the location of the data file as a URL.
 EscapeChar:Identifies the character to be used as an escape character in the data file. There is no default escape character.
 FieldDelim:Identifies the character that is used to mark the end of a field in the data file. The default character is the comma (,).
 Language:Specifies the language used to generate the data file (this specifier uses the HTML standard codes based on ISO 369). The default specifier is eng-us.
 TextQualifier:Specifies the optional character that surrounds a field.
 RowDelim:Identifies the character used to mark the end of each row of data. The default character is the newline (NL) character.
 UseHeader:Specifies whether the first line of the data file contains header information. The default value is FALSE.

1. TDC可配置参数还包括Filtering Properties、Sorting Properties,这里就不介绍了。
2. Reset用于根据TDC提供的数据刷新HTML节点。
TDC及数据集Recordset对象(不同的环境可能有些出入):
 属性:
 recordcount:记录总数。
 bof:如果当前的记录位置在第一条记录之前,则返回 true,否则返回 fasle。
 eof:如果当前记录的位置在最后的记录之后,则返回 true,否则返回 fasle。
 filter:返回一个针对 Recordset 对象中数据的过滤器。
 sort:设置或返回一个或多个作为 Recordset 排序基准的字段名。
 ……
 方法:
 movefirst:将游标移至第一条记录。
 movenext:将游标移至下一条记录。
 moveprevious:将游标移至上一条记录。
 movelast:将游标移至最后一条记录。
 addnew:添加记录。
 delete:删除记录。
 reset:根据设置的数据来源重置TDC控件的数据。
 ……
 事件:
 ondatasetcomplete:
 ondatasetchanged:
 onbeforeunload:
 onbeforeupdate:
 onreadystatechange:
 ……
 集合:
 fields:指示在此 Recordset 对象中 Field 对象。
 properties:包含所有 Recordset 对象中的 Property 对象。
 fields/properties集合的属性:
 count:返回集合中项目的数目。以 0 起始。
 item(named_item/number):返回集合中的某个指定的项目。
使用TDC来实现Ajax,实现步骤如下:
1、在页面加入TDC对应object控件
2、设置TDC数据来源并发送请求
dataurl为数据来源,reset方法即根据设置的url发送请求请求数据。
3、处理TDC数据请求
4、将处理结果封装成TDC对应数据格式
[color=blue]这里有几点需要注意的:
 输出数据的格式为“标题$数据行$……$数据行”,标题与数据行之间的分隔符同数据行与数据行之间的分隔符是一致的,与TDC控件中声明的RowDelim属性保持一致。数据结束时不能再输出分隔符,否则会再次当做一组空的数据处理。
 标题的格式为字段名称+字段类型,名称之间以逗号分割,这个与TDC控件中声明的FieldDelim属性保持一致。
 数据行的数据应与标题一一对应,数据与数据之间以逗号分割,这个与TDC控件中声明的FieldDelim属性保持一致。
 由于TDC默认是以换行为数据行的分割,这就会导致页面之中不能出现换行,否则会当成空的数据处理,这也导致了代码格式不规范——代码不能分行,可以通过设置RowDelim来解决该问题。
 由于页面格式的原因,可能导致数据之前会有很多空行,这样会导致第一个字段的名称不是实际的名称——包含了多个空行,目前有如下解决方案:
i. 将多行代码合并成一行,这样就避免了空行,但是这样会导致代码不规范,影响可读性。
ii. 在第一个字段前添加一个冗余字段作为新的第一个字段,这样实际的字段就不会出现该问题了。[/color]
5、TDC回调及数据处理
[color=green]TDC回调函数即对应的ondatasetcomplete事件[/color],在事件中遍历TDC数据集并执行相关操作
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值