• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFGRID Dropping Leading "0"

Community Beginner ,
Aug 03, 2008 Aug 03, 2008

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

396

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 03, 2008 Aug 03, 2008

Copy link to clipboard

Copied

Hi Jeff,

Have you tried this work around?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 22, 2008 Sep 22, 2008

Copy link to clipboard

Copied

Please re-post. No link or information to work around posted here?

~Calvert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 23, 2008 Sep 23, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 24, 2008 Sep 24, 2008

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation