|
 |
asp_ado_rds thread: Dynamically re-drawing table
Message #1 by "John Schwary" <schwary@w...> on Mon, 4 Jun 2001 04:31:10
|
|
Hello All,
I have run into a situation that I need help with and would greatly
appreciate anyone's ideas.
Allow the user to click a button that would re-draw the table of data,
with the last column (a checkbox) checked for every row.
Then, allow the user to click a different button that would re-draw the
table listing only those rows that have been selected, by checking the
last column of the row (a checkbox).
Cheers!
-John
Here is the bulk of my code as it is today...
default.asp
.
.
.
<!--#include FILE="resources/RDSProcedures2_TestDiseaseRegisty.asp"-->
<span id="spanAntiCoag"></span>
<table width="100%" border="0">
<tr>
<td width="24%"
class="footerLeft"> <img
src="images/sort.gif" height="25" width="32" onClick="hideAll();show
('sortSpan')" width="68" height="20"><br>Sort Preferences</td>
<td width="23%" class="footerLeft"
valign="top"> <input type="button"
value="<--" id="btnPrevious" onclick="vbScript: NextPreviousPage
('Previous')"><br>Previous Page</td>
<span id="spanNext">
<td width="23%" class="footerLeft"
valign="top"> <input type="button" value="-->"
id="btnNext" onclick="vbScript: NextPreviousPage('Next')"><br>Next
Page</td>
</span>
<td width="15%" class="footerCenter"><img src="images/printer.gif"
height="25" width="32" onClick="VBScript:PrintAll()"><br>Check All
Patients</td>
<td width="15%" class="footerCenter"><img src="images/printer.gif"
height="25" width="32" onClick="VBScript: PrintChecked()"><br>Print
Checked Patients</td>
</tr>
</table>
.
.
.
RDSProcedures2_TestDiseaseRegisty.asp
Sub Window_OnLoad()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure performs the following tasks:
' Retrieves the RDS data, passing logged on user's Logician
ID,
' and their Primary, Secondary, and Tertiary sort
perferences.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strLogicianLogin, strPrimarySort, strSecondarySort,
strTertiarySort
strLogin = LCase(document.frmAnticoag.Login.Value)
strPrimarySort = document.frmAnticoag.PrimarySort.Value
strSecondarySort = document.frmAnticoag.SecondarySort.Value
strTertiarySort = document.frmAnticoag.TertiarySort.Value
intRecordCount = GetRDSData (strLogin, strPrimarySort,
strSecondarySort, strTertiarySort)
CreateTable()
SetCellClass()
End Sub
Function GetRDSData(LogicianLogin, PrimarySort, SecondarySort,
TertiarySort)
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure retrieve the RDS data
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set objDiseaseRegistry = objRDS.CreateObject
("DiseaseRegistry.TestModule","http://localhost/projectTest")
If Err.Number then
MsgBox "Error: " & Err.Description
Else
' Retrieve the records
Set objRS = objDiseaseRegistry.GetAntiCoagDataSimpleTest
("Provider=OraOLEDB.Oracle;User ID=admin;Password=admin;Data
Source=cyz1Log;", Login)
If Err.number then
MsgBox "Error: " & Err.Description
Else
' Set the RDS Data Control's recordset
objRDC.ExecuteOptions = 1 '
adcExecSync
objRDC.FetchOptions = 1 '
adcFetchUpFront
objRDC.SourceRecordset = objRS
End If
End If
' Retrieve the total number of rows - will be used to determine
whether or
' not to display the next page button.
GetRDSData = objRS.RecordCount
' Clean up
Set objDiseaseRegistry = Nothing
Set objRS = Nothing
End Function
Sub CreateTable()
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure will create a table based on the output of the
recordset.
' The rows are in the order of the recordset.
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strCellColor, strCellName, strCellValue, i
Const adcReadyStateComplete = 4
If objRDC.ReadyState = adcReadyStateComplete Then
Dim strTable, strClass
strTable = "<table id='tblData' border='0'
datasrc='#objRDC' datapagesize='2'>" & Chr(13)
strTable = strTable & "<thead>" & Chr(13)
strTable = strTable & "<tr>" & Chr(13)
i = 0
For Each objField in objRDC.Recordset.Fields
strCellName = Trim(objRDC.Recordset.Fields
(i).Name)
strTable = strTable & "<th width='"& arrCellWidth
(i) &"' onMouseOver=javascript:this.style.cursor='hand'
onClick=vbscript:sort('" & Replace(strCellName, " ", "%20") & "')
class='headingCenter'>"& strCellName &"</th>" & Chr(13)
i = i + 1
Next
strTable = strTable & "</tr>" & Chr(13)
strTable = strTable & "</thead>" & Chr(13)
strTable = strTable & "<tbody>" & Chr(13)
objRDC.Recordset.MoveFirst
strTable = strTable & "<tr>" & Chr(13)
i = 0
For Each objField in objRDC.Recordset.Fields
strCellValue = Trim
(objRDC.Recordset.Fields(i).value)
strCellName = Trim(objRDC.Recordset.Fields
(i).name)
If strCellName = "Action" Then
strTable = strTable & "<td
id='action'><input type='checkbox' name='Print' value='" & strCellValue
& "' datafld='"& strCellName &"'></td>" & Chr
(13)
Else
strTable = strTable & "<td id='"&
strCellName &"'><span datafld='"& strCellName &"'></span></td>" & Chr
(13)
i = i + 1
End If
Next
strTable = strTable & "</tr>" & Chr(13)
strTable = strTable & "</tbody>" & Chr(13)
strTable = strTable & "</table>"
spanAntiCoag.innerhtml = strTable
End If
End Sub
Sub SetCellClass()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure sets the individual cell's class -
' classes are defined in the DiseaseRegistry.css file
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim x, iLoop
x = 1
objRDC.Recordset.MoveLast
Do While Not objRDC.Recordset.EOF
For iLoop = 0 to objRDC.Recordset.Fields.Count - 1
If objRDC.Recordset.Fields(iLoop).Name = "Status"
Then
' The status collumn is color coded - if
the Status is RED, then the background is Red
' if the status is GREEN, then the
background is Green
If objRDC.Recordset.Fields(iLoop).Value
= "RED" Then tblData.rows(x).cells(iLoop).className = "contentRed"
If objRDC.Recordset.Fields(iLoop).Value
= "GREEN" Then tblData.rows(x).cells(iLoop).className = "contentGreen"
Else
' Numeric Values get centered and String
Values get left justified
If len(objRDC.Recordset.Fields
(iLoop).Value) <> 0 Then
If isNumeric(left
(objRDC.Recordset.Fields(iLoop).Value,1)) Then
tblData.rows
(x).cells(iLoop).className = "contentCenter"
Else
tblData.rows
(x).cells(iLoop).className ="contentLeft"
End If
Else
tblData.rows(x).cells
(iLoop).className = "contentLeft"
End If
End If
Next
objRDC.Recordset.MoveNext
x = x + 1
Loop
End Sub
Message #2 by Josh King <JoshK@g...> on Mon, 4 Jun 2001 08:48:37 -0500
|
|
You could try using the {display: none} or the {visibility: hidden} style
attributes. Hide and display things based on the what the user presses-
Josh King
GeoAccess Inc.
xxx.xxx.xxxx x5237
xxx.xxx.xxxx x5237
-----Original Message-----
From: John Schwary [mailto:schwary@w...]
Sent: Sunday, June 03, 2001 11:31 PM
To: ASP_ADO_RDS
Subject: [asp_ado_rds] Dynamically re-drawing table
Hello All,
I have run into a situation that I need help with and would greatly
appreciate anyone's ideas.
Allow the user to click a button that would re-draw the table of data,
with the last column (a checkbox) checked for every row.
Then, allow the user to click a different button that would re-draw the
table listing only those rows that have been selected, by checking the
last column of the row (a checkbox).
Cheers!
-John
Here is the bulk of my code as it is today...
default.asp
.
.
.
<!--#include FILE="resources/RDSProcedures2_TestDiseaseRegisty.asp"-->
<span id="spanAntiCoag"></span>
<table width="100%" border="0">
<tr>
<td width="24%"
class="footerLeft"> <img
src="images/sort.gif" height="25" width="32" onClick="hideAll();show
('sortSpan')" width="68" height="20"><br>Sort Preferences</td>
<td width="23%" class="footerLeft"
valign="top"> <input type="button"
value="<--" id="btnPrevious" onclick="vbScript: NextPreviousPage
('Previous')"><br>Previous Page</td>
<span id="spanNext">
<td width="23%" class="footerLeft"
valign="top"> <input type="button" value="-->"
id="btnNext" onclick="vbScript: NextPreviousPage('Next')"><br>Next
Page</td>
</span>
<td width="15%" class="footerCenter"><img src="images/printer.gif"
height="25" width="32" onClick="VBScript:PrintAll()"><br>Check All
Patients</td>
<td width="15%" class="footerCenter"><img src="images/printer.gif"
height="25" width="32" onClick="VBScript: PrintChecked()"><br>Print
Checked Patients</td>
</tr>
</table>
.
.
.
RDSProcedures2_TestDiseaseRegisty.asp
Sub Window_OnLoad()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure performs the following tasks:
' Retrieves the RDS data, passing logged on user's Logician
ID,
' and their Primary, Secondary, and Tertiary sort
perferences.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strLogicianLogin, strPrimarySort, strSecondarySort,
strTertiarySort
strLogin = LCase(document.frmAnticoag.Login.Value)
strPrimarySort = document.frmAnticoag.PrimarySort.Value
strSecondarySort = document.frmAnticoag.SecondarySort.Value
strTertiarySort = document.frmAnticoag.TertiarySort.Value
intRecordCount = GetRDSData (strLogin, strPrimarySort,
strSecondarySort, strTertiarySort)
CreateTable()
SetCellClass()
End Sub
Function GetRDSData(LogicianLogin, PrimarySort, SecondarySort,
TertiarySort)
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure retrieve the RDS data
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set objDiseaseRegistry = objRDS.CreateObject
("DiseaseRegistry.TestModule","http://localhost/projectTest")
If Err.Number then
MsgBox "Error: " & Err.Description
Else
' Retrieve the records
Set objRS = objDiseaseRegistry.GetAntiCoagDataSimpleTest
("Provider=OraOLEDB.Oracle;User ID=admin;Password=admin;Data
Source=cyz1Log;", Login)
If Err.number then
MsgBox "Error: " & Err.Description
Else
' Set the RDS Data Control's recordset
objRDC.ExecuteOptions = 1 '
adcExecSync
objRDC.FetchOptions = 1 '
adcFetchUpFront
objRDC.SourceRecordset = objRS
End If
End If
' Retrieve the total number of rows - will be used to determine
whether or
' not to display the next page button.
GetRDSData = objRS.RecordCount
' Clean up
Set objDiseaseRegistry = Nothing
Set objRS = Nothing
End Function
Sub CreateTable()
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure will create a table based on the output of the
recordset.
' The rows are in the order of the recordset.
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim strCellColor, strCellName, strCellValue, i
Const adcReadyStateComplete = 4
If objRDC.ReadyState = adcReadyStateComplete Then
Dim strTable, strClass
strTable = "<table id='tblData' border='0'
datasrc='#objRDC' datapagesize='2'>" & Chr(13)
strTable = strTable & "<thead>" & Chr(13)
strTable = strTable & "<tr>" & Chr(13)
i = 0
For Each objField in objRDC.Recordset.Fields
strCellName = Trim(objRDC.Recordset.Fields
(i).Name)
strTable = strTable & "<th width='"& arrCellWidth
(i) &"' onMouseOver=javascript:this.style.cursor='hand'
onClick=vbscript:sort('" & Replace(strCellName, " ", "%20") & "')
class='headingCenter'>"& strCellName &"</th>" & Chr(13)
i = i + 1
Next
strTable = strTable & "</tr>" & Chr(13)
strTable = strTable & "</thead>" & Chr(13)
strTable = strTable & "<tbody>" & Chr(13)
objRDC.Recordset.MoveFirst
strTable = strTable & "<tr>" & Chr(13)
i = 0
For Each objField in objRDC.Recordset.Fields
strCellValue = Trim
(objRDC.Recordset.Fields(i).value)
strCellName = Trim(objRDC.Recordset.Fields
(i).name)
If strCellName = "Action" Then
strTable = strTable & "<td
id='action'><input type='checkbox' name='Print' value='" & strCellValue
& "' datafld='"& strCellName &"'></td>" & Chr
(13)
Else
strTable = strTable & "<td id='"&
strCellName &"'><span datafld='"& strCellName &"'></span></td>" & Chr
(13)
i = i + 1
End If
Next
strTable = strTable & "</tr>" & Chr(13)
strTable = strTable & "</tbody>" & Chr(13)
strTable = strTable & "</table>"
spanAntiCoag.innerhtml = strTable
End If
End Sub
Sub SetCellClass()
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This procedure sets the individual cell's class -
' classes are defined in the DiseaseRegistry.css file
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim x, iLoop
x = 1
objRDC.Recordset.MoveLast
Do While Not objRDC.Recordset.EOF
For iLoop = 0 to objRDC.Recordset.Fields.Count - 1
If objRDC.Recordset.Fields(iLoop).Name = "Status"
Then
' The status collumn is color coded - if
the Status is RED, then the background is Red
' if the status is GREEN, then the
background is Green
If objRDC.Recordset.Fields(iLoop).Value
= "RED" Then tblData.rows(x).cells(iLoop).className = "contentRed"
If objRDC.Recordset.Fields(iLoop).Value
= "GREEN" Then tblData.rows(x).cells(iLoop).className = "contentGreen"
Else
' Numeric Values get centered and String
Values get left justified
If len(objRDC.Recordset.Fields
(iLoop).Value) <> 0 Then
If isNumeric(left
(objRDC.Recordset.Fields(iLoop).Value,1)) Then
tblData.rows
(x).cells(iLoop).className = "contentCenter"
Else
tblData.rows
(x).cells(iLoop).className ="contentLeft"
End If
Else
tblData.rows(x).cells
(iLoop).className = "contentLeft"
End If
End If
Next
objRDC.Recordset.MoveNext
x = x + 1
Loop
End Sub
|
|
 |