?
Solved

Multiple DB fields and CFIF code in a cfgridcolumn?

Posted on 2005-03-17
5
Medium Priority
?
456 Views
Last Modified: 2013-12-24
Is it possible to have multiple DB fields to display in a cfgridcolumn?  Also, is it possible to put CFIF code within a cfgridcolumn as well?  The code below is just a quick example I put together.  Lets say I want to have a CFIF/CFELSE to do different things in the field?  ....and include an href IF one of those statements is true....

Example:

<cfquery name="OrderCount" datasource="#Portal.WebAppDSN#">
      SELECT      OrderNumber, Date, Product, TotalNumber
      FROM      Orders
</cfquery>

<cfform format="flash" width="700" height="150">
      <cfgrid name="OrderGrid" height="100" query="Orders">
            <cfgridcolumn name="Product" header="Product">
            <cfgridcolumn name="OrderNumber Date" header="Order Number and Date">
            <cfgridcolumn name="TotalNumber (if look here)" header="Total">
      </cfgrid>
</cfform>

I haven't been able to find a good example on the web that goes into more detail than the macromedia livedocs.

Thanks
0
Comment
Question by:Cardguy
[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
  • 3
  • 2
5 Comments
 

Author Comment

by:Cardguy
ID: 13569089
In addition to CFIFs, I also want to do some date math with DateDiffs.
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 13572170
Hi Cardguy!

What database are you using ???  I will be assuming that you are using SQL server.

> Is it possible to have multiple DB fields to display in a cfgridcolumn?
   YES, it is possible.  Just modify your query.

Try this :

<cfquery name="OrderCount" datasource="#Portal.WebAppDSN#">
  SELECT
    (OrderNumber + ' ' + Date) AS NumDate,
    Product, TotalNumber
  FROM Orders
</cfquery>

<cfform format="flash" width="700" height="150">
     <cfgrid name="OrderGrid" height="100" query="OrderCount">
          <cfgridcolumn name="Product" header="Product">
          <cfgridcolumn name="NumDate" header="Order Number and Date">
          <cfgridcolumn name="TotalNumber" header="Total">
     </cfgrid>
</cfform>

Hope this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 13572202
By the way, I forgot something.  Just a correction on my posted code which is I am referring it to you.

:: REVISED CODE ::
<cfquery name="OrderCount" datasource="#Portal.WebAppDSN#">
  SELECT
    (OrderNumber + ' ' + Date) AS NumDate,
    Product, TotalNumber
  FROM Orders
</cfquery>

<cfform name="form1" method="post">
     <cfgrid name="OrderGrid" height="100" query="OrderCount">
          <cfgridcolumn name="Product" header="Product">
          <cfgridcolumn name="NumDate" header="Order Number and Date">
          <cfgridcolumn name="TotalNumber" header="Total">
     </cfgrid>
</cfform>

*Note : No such attributes of "format, width and height" for "<cfform>" tag.  Refer to this macromedia livedocs : http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p38.htm#wp2433198


Regards!
eNTRANCE2002 :-)
0
 

Author Comment

by:Cardguy
ID: 13574098
SO there is no way to do it in the cfgridcolumn tag at all, is there?  It can only display one field per cell?  Are there any other solutions out there that can do it?

Also, as per the original question, I assume it isn't possible to put an cfif statement in the cell either, is there?  I need to have a cell display a number from the database.  If the number isn't there, then it needs to display a link to the page that allows you to enter it.
0
 
LVL 14

Accepted Solution

by:
Renante Entera earned 1500 total points
ID: 13580849
NO.  There's no way to do it in the "<cfgridcolumn>" tag.  It can only display one field per cell.  And as what I have posted, you can only do an alternative regarding displaying multiple DB field values per cell basing from your SQL statement.

In addition to that, you cannot put "<cfif>" statement within cell or any "<cf..>" tag.


Best regards!
eNTRANCE2002 :-)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

743 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