Skip to main content
Inspiring
November 15, 2006
Question

CFTable

  • November 15, 2006
  • 1 reply
  • 615 views
Is there a way to set the width of a CFTable without using divs? I know the cfcol tags have a width attribute, but that seems to be used for truncating data. Currently, my cftable goes all the way accross the window making it about 1000px too wide.

In addition, I can't seem to replace a NULL value with a space, either by using "nvl(value,' ') name" in the query, or <cfif isDefined("name")>text="#name#"<cfelse>text=" "</cfif> in the cfcol tag. This makes borders look terrible.

Thanks for any help!
    This topic has been closed for replies.

    1 reply

    November 15, 2006
    Please show us your code. (Just the essential stuff.)
    kodemonkiAuthor
    Inspiring
    November 16, 2006
    Does NOT display spaces.
    <cfquery name="getSSOdays" datasource="admi-prod">
    SELECT pa_code, dealer_id, dealership_name, nvl(mon,' ') mon, nvl(tue,' ') tue, nvl(wed,' ') wed, nvl(thu,' ') thu, nvl(fri,' ') fri
    FROM dealer_master
    WHERE dealer_id IN (select dealer_id from apm_alerts where assigned = 78)
    </cfquery>
    <body>
    <div style="width:450px;">
    <cfoutput>
    <cftable border="yes" query="getSSOdays" htmltable="yes" colspacing="0" colheaders="yes">
    <cfcol header="Dealer" align="left" width="10" text="#pa_code# - #dealership_name#">
    <cfcol header="Mon" align="center" width="1" text="#mon#">
    <cfcol header="Tue" align="center" width="1" text="#tue#">
    <cfcol header="Wed" align="center" width="1" text="#wed#">
    <cfcol header="Thu" align="center" width="1" text="#thu#">
    <cfcol header="Fri" align="center" width="1" text="#fri#">
    </cftable>
    </cfoutput>
    </div>

    This gives an error on if statement line (Invalid token found on line 17 at position 47. ColdFusion was looking at the following text: < Invalid expression element. The usual cause of this error is a misspelling in the expression text.
    <cfquery name="getSSOdays" datasource="admi-prod">
    SELECT pa_code, dealer_id, dealership_name, mon, tue, wed, thu, fri
    FROM dealer_master
    WHERE dealer_id IN (select dealer_id from apm_alerts where assigned = 78)
    </cfquery>
    <div style="width:450px;">
    <cfoutput>
    <cftable border="yes" query="getSSOdays" htmltable="yes" colspacing="0" colheaders="yes">
    <cfcol header="Dealer" align="left" width="10" text="#pa_code# - #dealership_name#">
    <cfcol header="Mon" align="center" width="1" <cfif mon EQ ''>text=" "<cfelse>text="#mon#"</cfif>>
    <cfcol header="Tue" align="center" width="1" text="#tue#">
    <cfcol header="Wed" align="center" width="1" text="#wed#">
    <cfcol header="Thu" align="center" width="1" text="#thu#">
    <cfcol header="Fri" align="center" width="1" text="#fri#">
    </cftable>
    </cfoutput>
    </div>
    November 28, 2006
    The docs for cfcol suggest that if your cftable has the htmltable attribute, the width attribute on cfcol is a percentage. So you just need to work out how you want to split your columns. Incidentally, how do you set table width with a div? Also, have you looked into cfgrid with the flash format?

    quote:

    Column width. If the length of data displayed exceeds this value, data is truncated to fit. To avoid this, use an HTML table tag. If the surrounding cftable tag includes the htmltable attribute, width specifies the percent of the table width and it does not truncate text; otherwise, width specifies the number of characters.