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() :: code to convert row to column
<!--- 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>
Ginger CMS
the future of cms, a simple and intuitive content management system ... ASP.NET MVC Application
best practices like Repository, LINQ, Dapper, Domain objects ... CFTurbine
cf prototyping engine, generates boilerplate code and views ... Search Engine LITE
create your own custom search engine for your web site ... JRun monitor
monitors the memory footprint of JRun engine and auto-restarts a hung engine ... Validation Library
complete validation library for your web forms ...
the future of cms, a simple and intuitive content management system ... ASP.NET MVC Application
best practices like Repository, LINQ, Dapper, Domain objects ... CFTurbine
cf prototyping engine, generates boilerplate code and views ... Search Engine LITE
create your own custom search engine for your web site ... JRun monitor
monitors the memory footprint of JRun engine and auto-restarts a hung engine ... Validation Library
complete validation library for your web forms ...