4 Replies Latest reply on Sep 24, 2008 11:56 PM by Daverms

    CFGRID Dropping Leading "0"

    jgould
      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},{cfgridsortcolu mn},{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.