
Tabular Data Control(TDC)实现Ajax简介
发布日期:2022-02-24 11:36:09
浏览次数:6
分类:技术文章
本文共 2657 字,大约阅读时间需要 8 分钟。
首先简单介绍下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数据集并执行相关操作转载地址:https://blog.csdn.net/iteye_5883/article/details/82478010 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2023年09月20日 18时57分50秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
C++ 标准库读书杂记一
2019-03-07
C++ 标准库读书杂记7 Smart Pointer
2019-03-07
用Python获取英雄联盟所有皮肤图片
2019-03-07
.net core API 项目中的Swagger的简单使用
2019-03-07
8. .NET5微服务中的Apollo配置
2019-03-07
4.建造者模式(Builder Pattern)
2019-03-07
5.原型模式(Prototype Pattern)
2019-03-07
8.装饰器模式(Decorator Pattern)
2019-03-07
9.组合模式(Composite Pattern)
2019-03-07
10.外观模式(Facade Pattern)
2019-03-07
12.代理模式(Proxy Pattern)
2019-03-07
Linux里面的使用帮助
2019-03-07
JAVA入门
2019-03-07
C语言回调函数理解和使用
2019-03-07
Ubuntu构建根文件
2019-03-07
单片机为啥几乎不用malloc free
2019-03-07
MQTT cJSONS资料
2019-03-07
source insight 4.0 代码函数变量符号高亮
2019-03-07
keil watch窗口看模块全局变量
2019-03-07
Ubuntu下创建虚拟调试串口
2019-03-07