Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## index.cfm
- <html>
- <head><title>Hello World</title></head>
- <body>
- <cfform name="jokes">
- <center>
- <table border="0" cellspacing="20">
- <tr>
- <td>
- <cf_grid type="drunk" pagesize="20" width="600">
- </td>
- <td>
- <cf_grid type="stoner" pagesize="20" width="600">
- </td>
- </tr>
- </table>
- </center>
- </cfform>
- </body>
- </html>
- ## grid.cfm
- <cfset type = attributes.type>
- <cfif type eq ''>
- You must supply a type
- <cfelse>
- <cfgrid
- format="html"
- name="grid_#type#jokes"
- pagesize=#attributes.pagesize#
- selectmode="row"
- bind="cfc:v7db.getJokes({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},'#type#')"
- >
- <cfgridcolumn name="ID" display="No">
- <cfgridcolumn name="Line" header="#type# Jokes" width="#attributes.width#">
- </cfgrid>
- </cfif>
- ## v7db.cfc
- <cfcomponent>
- <cffunction name="getJokes" access="remote" returntype="struct">
- <cfargument name="page" required="yes">
- <cfargument name="pagesize" required="yes">
- <cfargument name="gridsortcolumn" required="yes">
- <cfargument name="gridsortdirection" required="yes">
- <cfargument name="type" required="yes">
- <cfset typename=#type#>
- <cfif typename eq 'stoner'>
- <cfset typename="stoned">
- </cfif>
- <cfquery name="jokes" datasource="orion_viper7">
- SELECT `ID`, concat('You know you\'re #typename# when ', `Line`) as Line FROM `#type#jokes`
- <cfif gridsortcolumn neq ''>
- ORDER BY #gridsortcolumn# #gridsortdirection#
- </cfif>
- </cfquery>
- <cfreturn queryConvertForGrid(jokes, page, pagesize) >
- </cffunction>
- </cfcomponent>
Add Comment
Please, Sign In to add comment