running tables

Ketan Jetty
enthusiasm for technology

running tables

Running Tables is a concept in displaying data in an easier to read and understand column wise arrangement instead of the row wise arrangement.

This functionality was welcomed by the developers in my company and has become a DeFacto standard within our company and is used by the development and testing teams to verify the database entries. The code is given below, in case, somebody would like to use it.

users
NAME kumar xin tom
PASSWORD pwd001 pwd002 pwd003
PHONE 800-123-1234 800-123-5678 -145.87

getDataColumnWise()
<!--- How to use this function.
#getDataColumnWise("types",qsTypes)#
--->

<cffunction name="getDataColumnWise" returntype="string">
	<cfargument name="t" type="string" hint="table name" />
	<cfargument name="q" type="query" hint="query object" />
	
	<cfset var retVal = "" />
	<cfset var colspanNum = arguments.q.recordCount + 1 />
	
	<cfoutput>
	<cfsavecontent variable="retVal">
		<table cellpadding="2" cellspacing="0">
		<tr><td colspan="#colspanNum#" class="tableName">#arguments.t#</td></tr>
		<cfloop list="#arguments.q.columnList#" index="c">
			<tr>
				<td class="columnName">
					#c#
				</td>
				<cfloop query="arguments.q">
					<cfset tempCol = "#c#[#arguments.q.currentRow#]" />
					<cfset tempData = evaluate(tempCol)>
					<td <cfif IsNumeric(tempData) AND tempData LT 0>
							class="columnValueRed"
						<cfelse>
							class="columnValue"</cfif> >
							#tempData#
					</td>
				</cfloop>
			</tr>
		</cfloop>
		</table>
	</cfsavecontent>
	</cfoutput>
	
	<cfreturn retVal />
</cffunction>

style sheet for getDataColumnWise()
<style>
	.tableName
	{	font-size: 11px;
		font-weight: bolder;
		font-family: sans-serif;
		border: 1px solid grey;
		background: yellow;
	}
	
	.columnName
	{	font-size: 10px;
		font-family: sans-serif;
		border: 1px solid grey;
		border-top: 0px;
	}
		
	.columnValue
	{	font-size: 10px;
		font-family: sans-serif;
		color: blue;
		border: 1px solid grey;
		border-left: 0px;
		border-top: 0px;
	}
	
	.columnValueRed
	{	font-size: 10px;
		font-family: sans-serif;
		color: red;
		border: 1px solid grey;
		border-left: 0px;
		border-top: 0px;
	}
</style>

coldfusion


CF Quick Reference


Ginger CMS
the future of cms, a simple, easy and intutive content management system ... more


CFTurbine
cf prototyping engine, generates boilerplate code and ... more


Jrun monitor
monitor and timely auto-restart to avoid Jrun hang ... more


Inheritance Config.
uses OOPs inheritance to create configuration file ... more


Real Estate App.
complete real estate application using data from MLS ... more


Search Engine Lite
create your own search engine for your web site ... more