Exemple de propriétés FilterColumn, FilterCriterion, FilterValue, SortColumn et SortDirection, et de méthode Reset (VBScript)
Important
À compter de Windows 8 et Windows Server 2012, les composants serveur RDS ne sont plus inclus dans le système d’exploitation Windows (voir le Guide pratique sur la compatibilité de Windows Server 2012 et Windows 8 pour plus de détails). Les composants clients RDS seront supprimés dans une version ultérieure de Windows. Évitez d'utiliser cette fonctionnalité dans de nouveaux travaux de développement, et prévoyez de modifier les applications qui utilisent actuellement cette fonctionnalité. Les applications qui utilisent RDS doivent migrer vers WCF Data Service.
Le code suivant montre comment définir le service Bureau à distance. Paramètre DataControl Server au moment du design et liez-le à une table HTML prenant en compte les données à l’aide d’une source de données. Coupez et collez le code suivant dans Notepad ou un autre éditeur de texte et enregistrez-le sous le nom FilterColumnVBS.asp.
<!-- BeginFilterColumnVBS -->
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection
Properties and Reset Method Example (VBScript)</TITLE>
</HEAD>
<BODY>
<h1>FilterColumn, FilterCriterion, FilterValue, SortColumn, and SortDirection
Properties and Reset Method Example (VBScript)</h1>
<OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
ID=RDS HEIGHT=1 WIDTH=1>
<PARAM NAME="SQL" VALUE="Select FirstName, LastName, Title, ReportsTo, Extension from Employees">
<PARAM NAME="SERVER" VALUE="<%=Request.ServerVariables("SERVER_NAME")%>">
<PARAM NAME="CONNECT" VALUE="Provider=SQLOLEDB;Initial Catalog=Northwind;Integrated Security=SSPI">
</OBJECT>
Sort Column: <SELECT NAME="cboSortColumn">
<OPTION VALUE=""></OPTION>
<OPTION VALUE=ID>ID</OPTION>
<OPTION VALUE=FirstName>FirstName</OPTION>
<OPTION VALUE=LastName>LastName</OPTION>
<OPTION VALUE=Title>Title</OPTION>
<OPTION VALUE=Title>ReportsTo</OPTION>
<OPTION VALUE=Phone>Extension</OPTION>
</SELECT>
<br>
Sort Direction: <SELECT NAME="cboSortDir">
<OPTION VALUE=""></OPTION>
<OPTION VALUE=TRUE>Ascending</OPTION>
<OPTION VALUE=FALSE>Descending</OPTION>
</SELECT>
<HR WIDTH="25%">
Filter Column: <SELECT NAME="cboFilterColumn">
<OPTION VALUE=""></OPTION>
<OPTION VALUE=FirstName>FirstName</OPTION>
<OPTION VALUE=LastName>LastName</OPTION>
<OPTION VALUE=Title>Title</OPTION>
<OPTION VALUE=Room>ReportsTo</OPTION>
<OPTION VALUE=Phone>Extension</OPTION>
</SELECT>
<br>
Filter Criterion: <SELECT NAME="cboCriterion">
<OPTION VALUE=""></OPTION>
<OPTION VALUE="=">=</OPTION>
<OPTION VALUE=">">></OPTION>
<OPTION VALUE="<"><</OPTION>
<OPTION VALUE=">=">>=</OPTION>
<OPTION VALUE="<="><=</OPTION>
<OPTION VALUE="<>"><></OPTION>
</SELECT>
<br>
Filter Value: <INPUT NAME="txtFilterValue">
<HR WIDTH="25%">
<INPUT TYPE=BUTTON NAME=Clear VALUE="CLEAR ALL">
<INPUT TYPE=BUTTON NAME=SortFilter VALUE="APPLY">
<HR>
<TABLE DATASRC=#RDS ID="DataTable">
<THEAD>
<TR>
<TH>FirstName</TH>
<TH>LastName</TH>
<TH>Title</TH>
<TH>Reports To</TH>
<TH>Extension</TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD>
<TD><SPAN DATAFLD="Title"></SPAN></TD>
<TD><SPAN DATAFLD="ReportsTo"></SPAN></TD>
<TD><SPAN DATAFLD="Extension"></SPAN></TD>
</TR>
</TBODY>
</TABLE>
<Script Language="VBScript">
<!--
Const adFilterNone = 0
Sub SortFilter_OnClick
Dim vCriterion
Dim vSortDir
Dim vSortCol
Dim vFilterCol
' The value of SortColumn will be the
' value of what the user picks in the
' cboSortColumn box.
vSortCol = cboSortColumn.options(cboSortColumn.selectedIndex).value
If(vSortCol <> "") then
RDS.SortColumn = vSortCol
End If
' The value of SortDirection will be the
' value of what the user specifies in the
' cboSortdirection box.
If (vSortCol <> "") then
vSortDir = cboSortDir.options(cboSortDir.selectedIndex).value
If (vSortDir = "") then
MsgBox "You must select a direction for the sort."
Exit Sub
Else
If vSortDir = "Ascending" Then vSortDir = "TRUE"
If vSortDir = "Descending" Then vSortDir = "FALSE"
RDS.SortDirection = vSortDir
End If
End If
' The value of FilterColumn will be the
' value of what the user specifies in the
' cboFilterColumn box.
vFilterCol = cboFilterColumn.options(cboFilterColumn.selectedIndex).value
If(vFilterCol <> "") then
RDS.FilterColumn = vFilterCol
End If
' The value of FilterCriterion will be the
' text value of what the user specifies in the
' cboCriterion box.
vCriterion = cboCriterion.options(cboCriterion.selectedIndex).value
If (vCriterion <> "") Then
RDS.FilterCriterion = vCriterion
End If
' txtFilterValue is a rich text box
' control. The value of FilterValue will be the
' text value of what the user specifies in the
' txtFilterValue box.
If (txtFilterValue.value <> "") Then
RDS.FilterValue = txtFilterValue.value
End If
' Execute the sort and filter on a client-side
' Recordset based on the specified sort and filter
' properties. Calling Reset refreshes the result set
' that is displayed in the data-bound controls to
' display the filtered, sorted recordset.
RDS.Reset
End Sub
Sub Clear_onClick()
'clear the HTML input controls
cboSortColumn.selectedIndex = 0
cboSortDir.selectedIndex = 0
cboFilterColumn.selectedIndex = 0
cboCriterion.selectedIndex = 0
txtFilterValue.value = ""
'clear the filter
RDS.FilterCriterion = ""
RDS.Reset(FALSE)
End Sub
-->
</Script>
</BODY>
</HTML>
<!-- EndFilterColumnVBS -->
Voir aussi
DataControl, objet (RDS)
FilterColumn, propriété (RDS)
FilterCriterion, propriété (RDS)
FilterValue, propriété (RDS)
Reset, méthode (RDS)
SortColumn, propriété (RDS)
SortDirection, propriété (RDS)
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour