TDC的类标识符 CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83
TDC的属性:
DataSrc: 数据文件。
Datafld: 数据列。
Dataformats: 数据格式,html,text等。
Datapagesize: 每页行数。
TDC控件定义:
<OBJECT id=控件名 CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="数据文件名">
<PARAM NAME="UseHeader" VALUE="True">
<PARAM NAME="Filter" VALUE="过滤条件">
<PARAM NAME="Sortcolumn" VALUE="排序列">
appenddata:是否新增数据库纪录。
charset :数据库是否忽略大小写。
dataUrl: 数据库地址。
EscapeChar :设置脱溢字符。
fieldDelim :设置数据位分格幅,默认为","
language: 默认值为english
recordset :设置数据集。
sort: 排序方式。
UseHeader :设置第一行是否为标题行。
选择显示记录 演示
功能:用下拉菜单选择显示某个部门,会显示某个部门的记录。
<!--TDC-5.htm-- ,显示data.txt的内容-->
<HTML><HEAD><TITLE>用下拉菜单选择显示某个部门,显示data.txt的内容</TITLE>
<Script language="VBscript">
sub menu_onclick()
samp.filtercolumn="bm"
if menu.selectedindex=0 then
samp.filterCriterion="<>"
samp.filterValue="no value"
else
samp.filterCriterion="="
select case menu.selectedindex
case 1
samp.filterValue="办公室"
case 2
samp.filterValue="计划科"
case 3
samp.filterValue="管理科"
case 4
samp.filterValue="生产科"
end select
end if
samp.reset()
End Sub
</Script>
<BODY>
<H2>用下拉菜单选择显示某个部门记录</H2>
<OBJECT align=baseline classid=clsid:333C7BC4-460F-11D0-BC04-0080C7055A83
id=samp>
<PARAM NAME="DataURL" VALUE="data.txt">
<PARAM NAME="UseHeader" VALUE="True">
</OBJECT>
<center>
<select style="width:150" id=menu>
<option selected value=all>全部
<option value=1>办公室
<option value=2>计划科
<option value=3>管理科
<option value=4>生产科
</select>
</center>
<TABLE border=1 dataSrc=#samp bordercolor=red>
<THEAD>
<TR>
<TH >职工编号</TH>
<TH >姓名</TH>
<TH >部门</TH>
<TH >住宅电话</TH></TR>
<TBODY>
<TR>
<TD><SPAN dataFld=BH></SPAN></TD>
<TD><SPAN dataFld=XM></SPAN></TD>
<TD><SPAN dataFld=BM></SPAN></TD>
<TD><SPAN dataFld=DH></SPAN></TD>
</TR></TBODY></TABLE><!--结束--></BODY></HTML>
数据排序显示 演示
Method!:
功能:用鼠标单击某列表头,会重新显示排序后的记录。
<!--TDC-4.htm-->
<HTML><HEAD><TITLE>显示排序记录,显示data.txt的内容</TITLE>
<Script language="VBscript">
sub bh1_onclick()
samp.Sortcolumn="bh"
samp.reset()
End Sub
sub xm1_onclick()
samp.Sortcolumn="xm"
samp.reset()
End Sub
sub bm1_onclick()
samp.Sortcolumn="bm"
samp.reset()
End Sub
sub dh1_onclick()
samp.SortColumn="dh"
samp.reset()
End Sub
</Script>
<BODY>
<H2>显示排序记录(单击某列表头)</H2>
<OBJECT align=baseline classid=clsid:333C7BC4-460F-11D0-BC04-0080C7055A83
id=samp>
<PARAM NAME="DataURL" VALUE="data.txt">
<PARAM NAME="UseHeader" VALUE="True">
</OBJECT>
<TABLE border=1 dataSrc=#samp bordercolor=red>
<THEAD>
<TR>
<TH id=bh1>职工编号</TH>
<TH id=xm1>姓名</TH>
<TH id=bm1>部门</TH>
<TH id=dh1>住宅电话</TH></TR>
<TBODY>
<TR>
<TD><SPAN dataFld=BH></SPAN></TD>
<TD><SPAN dataFld=XM></SPAN></TD>
<TD><SPAN dataFld=BM></SPAN></TD>
<TD><SPAN dataFld=DH></SPAN></TD>
</TR></TBODY></TABLE><!--结束--></BODY></HTML>
Method2:Sorting a Tabular Data Control using scripting
<OBJECT ID="studentgrades" CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="studentgrades.txt">
<PARAM NAME="UseHeader" VALUE="TRUE">
<PARAM NAME="TextQualifier" VALUE="~">
<PARAM NAME="FieldDelim" VALUE="|">
</OBJECT>
<TABLE DATASRC="#studentgrades" BORDER="2">
<THEAD>
<TH><a href="javascript:sortbyname()">Name</a></TH>
<TH><a href="javascript:sortbygrade()">Final Grade</a></TH>
</THEAD>
<TR>
<TD><SPAN DATAFLD="name"></SPAN></TD>
<TD align="center"><SPAN DATAFLD="grade"></SPAN></TD>
</TR>
</TABLE>
<SCRIPT type="text/javascript">
var tdcobj=document.all.studentgrades
var sortnamestring="-name"
var sortgradestring="-grade"
function sortbyname(){
sortnamestring=(sortnamestring!="+name")? "+name" : "-name"
tdcobj.Sort=sortnamestring
tdcobj.reset()
}
function sortbygrade(){
sortgradestring=(sortgradestring!="+grade")? "+grade" : "-grade"
tdcobj.Sort=sortgradestring
tdcobj.reset()
}
</SCRIPT>
<TH><A HREF="javascript:SortBy('CustomerID');">Customer ID</A></TH>
Method3:Sorting a Tabular Data Control using the <PARAM> tag
· <PARAM name="Sort" value="+-column_name">
where "columname" is the name of the column you wish to sort the displayed information using, with a "+" indicating ascending, and "-" indicating descending. This applies to both alphabetical and numerical column types.
Lets see what I mean by creating a simple student grades TDC, and sort this information by grade before displaying it (descending):
<table border ID=tblElements datasrc=#tdcElements DATAPAGESIZE=10
width="800" border="1" cellpadding="0" cellspacing="1">
<THEAD>
<tr class="table_level_3">
<TH width="3%" id="getStationeryID"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_ID"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" />
<TH width="20%" id="getStationeryName"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_NAME"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" /></TH>
<TH width="13%" id="getStationeryStock"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_STOCKQTY"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" /></TH>
<TH width="6%" id="getStationeryPrice"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_PRICE"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" /></TH>
<TH width="16%" id="getMaxAppliedQuantity"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_MAXAPPLIEDQTY"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" /></TH>
<TH width="24%" id="getStationeryDescription"><bean:message
key="LBL_FLD_KISS_EMPSRV_STATIONERY_DESCRIPTION"
bundle="BUNDLE_FLD_KISS_EMPLOYEESERVICE" /></TH>
</tr>
</THEAD> <table border id="tdcElements" datasrc="#tdcElements" DATAPAGESIZE="10" width="800" border="1" cellpadding="0" cellspacing="1"><THEAD><tr class="table_level_3"><th width="3%" id="getStationeryID">null</TH><th width="20%" id="getStationeryName">null</TH><th width="13%" id="getStationeryStock">null</TH><th width="6%" id="getStationeryPrice">null</TH><th width="16%" id="getMaxAppliedQuantity">null</TH><th width="24%" id="getStationeryDescription">null</TH>
<OBJECT id=tdcElements
CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="myfile.csv">
<PARAM NAME="UseHeader" VALUE="True">
<PARAM NAME="TextQualifier" VALUE="'">
<PARAM NAME="Sort" VALUE="+getStationeryID">
</OBJECT>
<TBODY>
<tr class="table_level_2">
<TD>
<DIV datafld="getStationeryID"></DIV>
</TD>
<TD>
<DIV datafld="getStationeryName"></DIV>
</TD>
<TD>
<DIV datafld="getStationeryStock"></DIV>
</TD>
<TD>
<DIV datafld="getStationeryPrice"></DIV>
</TD>
<TD>
<DIV datafld="getMaxAppliedQuantity"></DIV>
</TD>
<TD>
<DIV datafld="getStationeryDescription"></DIV>
</TD>
</tr>
</TBODY>
</table>
<table width="800" border="1" cellpadding="0" cellspacing="1">
<tr class="table_level_2" colspan="8">
<td colspan="8" align="right"><SPAN STYLE="font-weight:bold"
ID=spanElemCount> </span> <!-- BUTTON ID=cmdnextPage onClick="tblElements.firstPage"><<</BUTTON-->
<BUTTON ID=cmdpreviousPage onClick="tblElements.previousPage()"><</BUTTON>
<BUTTON ID=cmdnextPage onClick="tblElements.nextPage()">></BUTTON>
<!-- BUTTON ID=cmdnextPage onClick="tblElements.lastPage">>></BUTTON-->
</td>
</tr>
event.srcElement.offsetParent.parentElement.rowIndex
event.srcElement.offsetParent.parentElement.cells[0].innerText