SHARE
TWEET

proses.cfc

a guest Feb 13th, 2017 291 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <cfcomponent>
  2.     <cffunction name="dataTable" access="remote" format="json">
  3.         <cfset sTableName = "TAccount" />
  4.         <cfset listColumns = "Account_Id,Account_Name,Account_Address1" />
  5.         <cfset sIndexColumn = "Account_Id" />
  6.         <cfset coldfusionDatasource = "dbcserpdev1608"/>
  7.         <cfparam name="url.sEcho" default="1" type="integer" />
  8.         <cfparam name="url.iDisplayStart" default="0" type="integer" />
  9.         <cfparam name="url.iDisplayLength" default="10" type="integer" />
  10.         <cfparam name="url.sSearch" default="" type="string" />
  11.         <cfparam name="url.iSortingCols" default="0" type="integer" />
  12.          
  13.         <!--- Data set after filtering --->
  14.         <cfquery datasource="#coldfusionDatasource#" name="qFiltered">
  15.             SELECT #listColumns#
  16.                 FROM #sTableName#
  17.             <cfif len(trim(url.sSearch))>
  18.                 WHERE <cfloop list="#listColumns#" index="thisColumn"><cfif thisColumn neq listFirst(listColumns)> OR </cfif>#thisColumn# LIKE <cfif thisColumn is "version"><!--- special case ---><cfqueryparam cfsqltype="CF_SQL_FLOAT" value="#val(url.sSearch)#" /><cfelse><cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="%#trim(url.sSearch)#%" /></cfif></cfloop>
  19.             </cfif>
  20.             <cfif url.iSortingCols gt 0>
  21.                 ORDER BY <cfloop from="0" to="#url.iSortingCols-1#" index="thisS"><cfif thisS is not 0>, </cfif>#listGetAt(listColumns,(url["iSortCol_"&thisS]+1))# <cfif listFindNoCase("asc,desc",url["sSortDir_"&thisS]) gt 0>#url["sSortDir_"&thisS]#</cfif> </cfloop>
  22.             </cfif>
  23.         </cfquery>
  24.          
  25.         <!--- Total data set length --->
  26.         <cfquery datasource="#coldfusionDatasource#" name="qCount">
  27.             SELECT COUNT(#sIndexColumn#) as total
  28.             FROM   #sTableName#
  29.         </cfquery>
  30.          
  31.         <!---
  32.             Output
  33.          --->
  34.         <cfcontent reset="Yes" />
  35.         {"sEcho": <cfoutput>#val(url.sEcho)#</cfoutput>,
  36.         "iTotalRecords": <cfoutput>#qCount.total#</cfoutput>,
  37.         "iTotalDisplayRecords": <cfoutput>#qFiltered.recordCount#</cfoutput>,
  38.         "aaData": [
  39.             <cfoutput query="qFiltered" startrow="#val(url.iDisplayStart+1)#" maxrows="#val(url.iDisplayLength)#">
  40.                 <cfif currentRow gt (url.iDisplayStart+1)>,</cfif>
  41.                 [<cfloop list="#listColumns#" index="thisColumn"><cfif thisColumn neq listFirst(listColumns)>,</cfif><cfif thisColumn is "version"><cfif version eq 0>"-"<cfelse>"#replacenocase(jsStringFormat(version),"\'","'","all")#"</cfif><cfelse>"#replacenocase(jsStringFormat(qFiltered[thisColumn][qFiltered.currentRow]),"\'","'","all")#"</cfif></cfloop>]
  42.             </cfoutput> ] }
  43.     </cffunction>
  44. </cfcomponent>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top