Solved

How to trun off display the CFCOL header in CFTABLE

Posted on 2006-11-11
10
449 Views
Last Modified: 2013-12-24
Using CFTABLE below creates an empty line for each text file found with cfdirectory. I've been able to turn off the actual name but where the name should be is still a line feed, horribly screwing up my page, ending up with far too many empty lines on my page, and pushes my resulting #keywords# variable far down the page. I don't need the attributes of cfdirectory or cftable.

 How can I turn off the hidden "NAME" display of CFTABLE and therefore the blank line feeds?

 - Georgia

<CFDIRECTORY DIRECTORY="c:\keywords" NAME="myDirectory" filter="*.txt">
<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

<form name="form1" method="post" action="">
   <select name="Filename">
      <option value=""><cfoutput>#FileName#</cfoutput></option>
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
   <input type="submit" name="SubmitButton" value="submit">
</form>
<cfoutput>
   <cffile action="read" file="c:\keywords\#Filename# " variable="keywords">
</cfoutput>
<cfif IsDefined("SubmitButton")>
   <cfoutput>#keywords#</cfoutput>
</cfif>

I've been able to workaround this by using a DIV statement and an absolute page setting with CSS, but would rather solve the actual problem, if possible.
0
Comment
Question by:RollinNow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 7

Expert Comment

by:aseusainc
ID: 17925253
Could always just build the table manually.

<cftable>
<cfoutput query="myDirectory">
<tr>
<td>#somevariable#</td>
<td>#anothervariable</td>
<td>#somethingelse#</td>
</tr>
</cfoutput>
</table>
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17925746

 Hi Georgia,

 What is the purpose of your CFTABLE in the code above?   The reason I ask is because it doesn't appear you're trying to show any data in the CFTABLE, but just put in the column heading "NAME:"

Please check out this code, I'm trying to guess your intent and see if its helps ...


This looks like the submit part, let's move it to the top and put the CFFILE read into the CFIF so its only called when submitted...

<cfif IsDefined("SubmitButton")>
    <cffile action="read" file="c:\keywords\#form.Filename# " variable="keywords">
    <cfoutput>#cffile.keywords#</cfoutput>  
</cfif>


<form name="form1" method="post">   <!---- no action, form will post to same page ---->
 <table>
   <tr>
    <td>NAME: </td>  <!----- here is the column heading for the select box ----->
    <td>
   <select name="Filename">
      <option value="" selected>- Select a File -      <!----- Note the change here, is this what you wanted here? ----->
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
    </td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" name="SubmitButton" value="submit">
      </td>
    </tr>
</table>
</form>

0
 

Author Comment

by:RollinNow
ID: 17927508
Aseusainc,

Not sure what to make of your suggestion. It seems there needs to be at least one CFCOL defined so that doesn't seem to work.

 - Georgia
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

Author Comment

by:RollinNow
ID: 17927529
Gdemaria,

> What is the purpose of your CFTABLE

So I can have a query output for mydirectory: <cfloop query = "mydirectory">

I had to use CFDIRECTORY to get the  list of files  and someway to loop through it. I didn't know how to loop through an index or so found that  code somewhere on EE.

Everything is working, it's just that the CFTABLE is used to set the cfloop query but it requires the table output and I don't see a way to turn it off.

Your code is the same result as what I have. I need something which does the same but either does not use cftable or can turn off the CFCOL output. I deleted the NAME which before looked like this:

<CFCOL HEADER="NAME:" TEXT="NAME">

Now at least it does not display the name, but does do the line feeds where a file in the directory was found. That's the problem. Am I making sense?

  - Georgia




0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17927560

 Hi Georgia,

 So, you would like to show all the files above your select list...

 The directory is..

   My Word Document.doc
   My Excel Document.xls
   A text file.tx

  Please choose a file:
  [ - select a file -    v ]     <--- that's a select box :)


 If so, something like this perhaps?

<table>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>


 If I'm not barking up the right tree, let me know what you want it to look like ...

 Cheers,
0
 
LVL 7

Assisted Solution

by:aseusainc
aseusainc earned 250 total points
ID: 17927629
Georgia,

Gdemaria's explaination is basically the same as I was getting at.  Added a decription row for clarity:

<table>
  <tr>
    <td>Filename</td>
  </tr>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>
0
 

Author Comment

by:RollinNow
ID: 17950714
It was my understanding that a cfoutput query requires that a query be defined. There is none. So how can I use either of your examples? It makes no sense to me.

I gave you all the code I'm using. The only time a query was set is with this line:

<CFTABLE QUERY="myDirectory">

I had never been familar with it until I ran over it here on EE and still am not sure how it works or why. But it seems obvious to me that it is the problem, other than my lack of experience and knowledge.

The trouble has to be me, but so far, I don't have a clue as to how either of you are getting to your suggestions and the examples certainly do not work, not with what you have shown so far.  Please take a look at the code I am using. There is nothing else, not query defined other than the cftable, if in fact, that is a defined query.

If this is not clear, then we cannot continue unless someone can help making it clear.  Query. That's the key. How is it defined, and how do I use it, in the code I have at the top of this page, and how to I use the cftable to, well, I've already stated this so there's no  reason to waste your time going over it again. I already have a workaround and I asked this question only to discover the answer, to learn something. Honest. But  nothing, absolutely nothing either of you have suggested makes any sense to me at all.

 - Georgia


0
 
LVL 39

Expert Comment

by:gdemaria
ID: 17951176

 The result of CFdirectory using the "list" action is a query.

 <CFDIRECTORY DIRECTORY="c:\keywords" NAME="myDirectory" filter="*.txt">
                                                                            ^^^^^^ this is the name of the query

When using the action = "list", cfdirectory returns five result columns you can reference in your cfoutput:

name   - Directory entry name.
size   -  Size of directory entry.
type    -  File type: File for File or Dir for Directory.
dateLastModified  -  Date an entry was last modified.
attributes   -   File attributes, if applicable.
mode   -  (For UNIX and Linux only)

You can use the following result columns in standard CFML expressions, preceding the result column name with the query name:

<cfoutput query="mydirectory">
#mydirectory.name#
#mydirectory.size#
#mydirectory.type#
#mydirectory.dateLastModified#
#mydirectory.attributes#
</cfquery>



 
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 250 total points
ID: 17951295

>  The only time a query was set is with this line:

 <CFTABLE QUERY="myDirectory">


 The CFtable tag takes an existing query and turns it into a table, outputting the query's columns in the rows and cells of the table.  

<cftable query = "myDirectory"  colSpacing = "3" HTMLTable>
   <cfcol header = "<B>File Name</B>"   align = "Left"  width = 2   text  = "#myDirectory.name#">
</cftable>

 This is the same as doing...

<table>
  <tr>
    <td>Filename</td>
  </tr>
 <cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>

aseusainc  and I prefer doing this second example over using CFTABLE because we like the control and its easier (in our opinion) to use and control (agreed, aseusainc?)


 So, therefore your initial code...

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

 Doesn't really make sense because you don't have any value in the TEXT="" field, you are just displaying an empty cell for every row of the query="mydirectory"

 The above command results in this...

<table>
  <tr>
    <td>NAME: </td>
  </tr>
  <tr>
    <td></td>  <!---- one empty row shown for each file returned in the CFDIRECTORY query ---->
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td></td>
  </tr>
 </table>

 
 That is why we were guiding you towards using this:

<table>
  <tr>
    <td>Filename</td>
  </tr>
<cfoutput query = "mydirectory">
  <tr>
    <td>#myDirectory.filename#</td>
  </tr>
 </cfoutput>
 </table>

 That will show the Filename heading and one row for each file in the directory.

 However, if you don't want to show all the files in the directory as I said on 1/12/2006 09:09PM EST

 The directory is..

   My Word Document.doc
   My Excel Document.xls
   A text file.tx

  Please choose a file:
  [ - select a file -    v ]     <--- that's a select box :)


 Then just completely remove this command

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>

 from your code, its really doing nothing at all, except showing the NAME: .



 If your goal IS to show the word NAME: next to the SELECT box, then refer to my comment above...  this will do it..


<form name="form1" method="post">   <!---- no action, form will post to same page ---->
 <table>
   <tr>
    <td>NAME: </td>  <!----- here is the column heading for the select box ----->
    <td>
   <select name="Filename">
      <option value="" selected>- Select a File -      <!----- Note the change here, is this what you wanted here? ----->
      <cfloop query = "mydirectory">
         <cfoutput>
            <option value="#mydirectory.name#">#mydirectory.name#</option>
         </cfoutput>
      </cfloop>
   </select>
    </td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" name="SubmitButton" value="submit">
      </td>
    </tr>
</table>
</form>


 So to directly answer this question:

>> How can I turn off the hidden "NAME" display of CFTABLE and therefore the blank line feeds?
                                      ^^^^  hidden??

 The answer is completely remove this command

<CFTABLE QUERY="myDirectory">
   <CFCOL HEADER="NAME:" TEXT="">
</CFTABLE>


 Hope that helps clear it up.  
0
 

Author Comment

by:RollinNow
ID: 17951377
That through me for a bit:

<cfoutput query="mydirectory"> </cfquery>

You meant <cfoutput query="mydirectory"> </cfoutput>

I don't need the cftable at all, nor do I need the cfoutput query. So, I just deleted the cftable code completely and left the rest of the code and it works as I want. Click. Finally. Hit me over the head next time!

I wish I had tried that first.  Thanks for the help from you both, and the instruction. Now I have to prepare for another storm here in Oregon. The last one knocked out our power for nearly two days.

 - Georgia


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What You Need to Know when Searching for a Webhost Provider
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question