Skip to main content
Inspiring
May 19, 2008
Question

Is this a bug in queryconvertforgrid

  • May 19, 2008
  • 2 replies
  • 492 views
queryconvertforgrid is trimming the leading zeros from returned query! Especially when I’m binding it with CFC.
When I run in debug mode I can see my numeric field “File Number” in this case trimmed and also there is a decimal separator.
The database variable type is varchar and most data starting with zeros. Is there anybody know what is going on?
I believe the grid should show the data as is without formatting to different format unless directed to.




    This topic has been closed for replies.

    2 replies

    Shirak76Author
    Inspiring
    May 22, 2008
    To go around this bug I've added space leading the zeros and just worked fine.
    Participant
    May 22, 2008
    Yes, that worked - thanks very much. I seem to remember encountering a similiar problem where adding one space was the fix. I just changed my SELECT to

    SELECT ' ' + MediaInventory.BarCodeNumber AS BarCode

    Happy Coding !
    June 19, 2008
    Wow..I've been google-ing around for weeks to get the solution for the trimming zero in my bind variable.Thanks so much for the solution.
    Participant
    May 22, 2008
    I am having the same issue. The data is varchar and has leading zeros, when it displays in the grid the zeros are removed. Please let us know when this can be fixed. In my code below the MediaInventory.BarCodeNumber is the field that has the leading zeros. CF8 is a HUGE improvement over CFMX7 - Thanks.

    <cfcomponent displayName="Inventory" hint="inv" output="false">
    <cfset THIS.dsn = "media">

    <cffunction name="getInventory" access="remote" returntype="struct">
    <cfargument name="page" type="numeric" required="yes">
    <cfargument name="pageSize" type="numeric" required="yes">
    <cfargument name="gridsortcolumn" type="string" required="no" default="">
    <cfargument name="gridsortdir" type="string" required="no" default="">
    <cfargument name="invhelper" type="string" required="no" default="">

    <!--- Local variables --->
    <cfset var inv="">
    <!--- Get data --->
    <cfquery name="inv" datasource="#THIS.dsn#">
    SELECT MediaInventory.BarCodeNumber,
    MediaInventory.Volume,
    MediaInventory.SerialNumber,
    MediaInventory.ClientNumber,
    MediaInventory.MatterNumber,
    MediaDescription.MediaDescription,
    MediaPurpose.MediaPurpose
    FROM MediaInventory INNER JOIN
    MediaDescription ON MediaInventory.MediaTypeID = MediaDescription.MediaTypeID INNER JOIN
    MediaPurpose ON MediaInventory.MediaPurposeID = MediaPurpose.MediaPurposeID

    <cfif ARGUMENTS.invhelper NEQ "">
    WHERE MediaInventory.BarCodeNumber LIKE '#ARGUMENTS.invhelper#%'
    </cfif>
    <cfif ARGUMENTS.gridsortcolumn NEQ ""
    and ARGUMENTS.gridsortdir NEQ "">
    ORDER BY #ARGUMENTS.gridsortcolumn# #ARGUMENTS.gridsortdir#
    <cfelse>
    ORDER BY MediaInventory.BarCodeNumber
    </cfif>

    </cfquery>

    <!--- And return it as a grid structure --->
    <cfreturn QueryConvertForGrid(inv,
    ARGUMENTS.page,
    ARGUMENTS.pageSize)>
    </cffunction>

    </cfcomponent>