Skip to main content
Participant
August 4, 2008
Question

CFGRID Dropping Leading "0"

  • August 4, 2008
  • 3 replies
  • 458 views
Using CFGRID, Format="HTML" and a bind to a cfc. The query returns zip_code properly from a varchar(15) column. I can display the results of the query in a simple table properly, so the zip code for, say, Amherst Massachusetts shows as "01002". However, the cfgridcolumn shows it as "1002".

<cfform name="GridForm">
<cfgrid name = "RestaurantGrid"
format = "HTML"
height = "320"
width = "570"
bind="cfc:inc.cfc.restaurant.getRestaurants({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection},'#sSid_Code#','#sRegion_Name#', '#sState_Code#' , '#sSearch_Name#')"
pagesize = "13"
sort = "Yes"
bgColor = "###sGridbgcolor#"
stripeRowColor = "###sGridstripeRowColor#"
stripeRows = "yes"
selectColor = "###sGridselectColor#"
selectMode = "row"
href = "oo.cfm"
hrefkey = "cnct_code"
appendKey = "Yes"
>
<cfgridcolumn name = "zip_code" header = "Zip" width = "100" dataalign = "left" headeralign = "left" >
</cfgrid>
</cfform>


The CFC . . .


<cfcomponent name = "restaurants" output = "no" hint="restaurants grid">
<cffunction name = "getRestaurants" access = "remote">
<cfargument name = "page" required = "yes">
<cfargument name = "pageSize" required = "yes">
<cfargument name = "gridsortcolumn" required = "yes">
<cfargument name = "gridsortdirection" required = "yes">
<cfargument name = "sSid_Code" required = "yes">
<cfargument name = "sRegion_Name" required = "yes">
<cfargument name = "sState_code" required = "yes">
<cfargument name = "sSearch_Name" required = "yes">

<cfquery name = "GridOutput" datasource="#sSid_Code#">
select zip_code
from vStores
where 1 = 1
<cfif IsDefined("sRegion_Name") AND sRegion_Name NEQ "ALL"> and Region_Name = '#sRegion_Name#' </cfif>
<cfif IsDefined("sState_Code") AND sState_code NEQ "ALL"> and State_Code = '#sState_Code#' </cfif>
<cfif IsDefined("sSearch_Name") AND sSearch_Name NEQ "ALL">
and ( address1_desc like '%#sSearch_Name#%'
or city_name like '%#sSearch_Name#%'
or zip_code like '%#sSearch_Name#%'
or buspart_name like '%#sSearch_Name#%'
)
</cfif>
<cfif gridsortcolumn neq ''>
order by #gridsortcolumn# #gridsortdirection#
<cfelse>
order by buspart_name
</cfif>
</cfquery>

<cfreturn queryconvertforgrid(GridOutput,page,pagesize)/>
</cffunction>
</cfcomponent>



Thanks.
This topic has been closed for replies.

3 replies

Inspiring
September 25, 2008
Inspiring
September 23, 2008
I've had the same problem and have to append a space before the varchar data that might have numeric data at their beginning that are being passed so AJAX or whatever the culprit is doesn't retype my data.
Inspiring
August 4, 2008
Hi Jeff,

Have you tried this work around?
September 23, 2008
Please re-post. No link or information to work around posted here?

~Calvert