Rev 13 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<%'============================================================='//'// Repeater'//'// version: 1.1'// last modified: 09-May-2004 03:03 by Sasha Vukovic'=============================================================%><%Class Repeater'Private mobjAccessControlPrivate mTableNamePrivate mRowIdPrivate mEnabledPrivate mDisabledPrivate mControlObjectPrivate mStartPositionPrivate mTotalRecordsPrivate mLastRecordPrivate mNavigatorPrivate MAX_ROWSPrivate objRsPrivate RS_NAMEPublic Property Let TableName ( sTableName )mTableName = sTableNameEnd PropertyPublic Property Let RowId ( sRowId )mRowId = sRowIdEnd PropertyPublic Property Let Row ( sRow )mEnabled = ConstructRow( sRow )End PropertyPublic Property Let Enabled ( sEnabled )mEnabled = sEnabledEnd PropertyPublic Property Let Disabled ( sDisabled )mDisabled = sDisabledEnd PropertyPublic Property Let ControlObject ( sControlObject )mControlObject = sControlObjectEnd PropertyPublic Property Let MaxRows ( nMaxRows )MAX_ROWS = nMaxRowsEnd PropertyPublic Property Let RecordSet ( ByRef oRs )Set objRs = oRsCall InitialiseNavigator()End Property'-----------------------------------------------------------------------------------------------------------------Public Sub Render ( ByRef oAccessControl )'--- Exit if Control Object is not supplied ---If IsNull(mControlObject) ThenErr.Raise 8, "Repeater requires Access Control object name before Render!", ""Exit SubEnd If' Access Control module suppliedIf oAccessControl.IsDataVisible ( mTableName, mRowId, mControlObject ) ThenIf oAccessControl.IsDataActive ( mTableName, mRowId, mControlObject ) ThenResponse.write mEnabledElseResponse.write mDisabledEnd IfEnd IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Public Sub RenderDataGrid ()'--- Render rows ---Do While (NOT objRs.BOF) AND (NOT objRs.EOF)If objRs.RowPosition => (mStartPosition + MAX_ROWS) Then Exit Do ' Limit the number of rows displayedResponse.write Eval( mEnabled )objRs.MoveNextLoopEnd Sub'-----------------------------------------------------------------------------------------------------------------Public Sub Navigator ( bResults, bNavigator )'== Definition ==Dim sResults, sNavigator'-- Create Results StringsResults = ""If bResults ThenIf mTotalRecords > 0 ThensResults = "Showing "& mStartPosition &" - "& mLastRecord &" of "& mTotalRecordsElsesResults = "No Results."End IfEnd If'-- Create Navigator StringsNavigator = ""If bNavigator ThensNavigator = mNavigatorEnd If'-- Display NavigatorResponse.write _"<table width='100%' border='0' cellspacing='5' cellpadding='0'>"&_" <tr>"&_" <td align='left' class='body_row'>"& sResults &"</td>"&_" <td align='right' class='body_scol'>"& sNavigator &"</td>"&_" </tr>"&_"</table>"End Sub'-----------------------------------------------------------------------------------------------------------------\Private Sub InitialiseNavigator ()Dim pageNumber'--- Get page number ---pageNumber = 0If Request("reppg") <> "" ThenpageNumber = CInt(Request("reppg"))End If'--- Set Cursor start position ---mStartPosition = pageNumber * MAX_ROWS + 1If (NOT objRs.BOF) AND (NOT objRs.EOF) ThenobjRs.MoveTo ( mStartPosition ) ' Set starting cursor pointEnd If'--- Construct mNavigatormNavigator = ""If (NOT objRs.BOF) AND (NOT objRs.EOF) ThenmTotalRecords = objRs.RecordCount ' Get total number of records'--- Create "Previous" linkIf pageNumber > 0 ThenmNavigator = mNavigator &"<a href='"& SCRIPT_NAME &"?reppg="& pageNumber - 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Previous Page'>« Previous</a>"End If'--- Create "Next" linkIf ( mStartPosition + MAX_ROWS ) <= mTotalRecords ThenmNavigator = mNavigator &" <a href='"& SCRIPT_NAME &"?reppg="& pageNumber + 1 &"&"& objPMod.ComposeURL() &"' class='body_link' title='Show Next Page'>Next »</a>"End IfEnd If'--- Calculate Last Record ---If mTotalRecords > 0 ThenmLastRecord = ( mStartPosition - 1 + MAX_ROWS ) _+ ( CInt( ( mStartPosition - 1 + MAX_ROWS )/mTotalRecords > 1) ) * ( ( mStartPosition - 1 + MAX_ROWS ) - mTotalRecords )End IfEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Function ConstructRow ( sRow )Dim tempSTRtempSTR = sRowtempSTR = Replace (tempSTR, "<#", " objRs(""" )tempSTR = Replace (tempSTR, "#>", """) " )ConstructRow = """"& tempSTR &""""End Function'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Initialize()'// Perform action on creation of object. e.g. Set myObj = New ThisClassNamemControlObject = NULLMAX_ROWS = 50 ' Max rows renderedRS_NAME = "objRs" ' Variable Name of the record set in this classEnd Sub'-----------------------------------------------------------------------------------------------------------------Private Sub Class_Terminate()'// Perform action on object disposal. e.g. Set myObj = NothingSet objRs = Nothing ' Record set objectEnd Sub'-----------------------------------------------------------------------------------------------------------------End Class%>