Link to home
Start Free TrialLog in
Avatar of etherealz
etherealz

asked on

display and hide field value

how can i display the column value and hide it for other rows?

e.g.

productNo name partNo partDescription
100          abc    01      light
                        02      bulb
                        03      plug
101           def    01      box
                        02      paper

as u can see the productno and name are not listed for the other rows. how do i do that in coldfusion language?

this is my attempt:

    <cfoutput query="showProductComponents">
         <tr>
               <cfif productNo1 is "">
               <cfset productNo1 = #showComponents.productNo#>
               <cfelse>
               <cfset productNo2 = #showComponents.productNo#>
               </cfif>
                           
           <td>#productNo#</td>
               <td>#showComponents.Name#</td>
               <td>#showComponents.partNo#</td>
               <td>#showComponents.description#</td>
               
         </tr>
      </cfoutput>
Avatar of danrosenthal
danrosenthal

how about this:

<cfoutput query="showProductComponents" group="productNo">
      <CFSET headerrow = 1>
      <tr>
            <td>#productNo#</td>
            <td>#Name#</td>
      <CFOUTPUT>
            <CFIF headerrow neq 1><TR><TD></td><TD></td></cfif>
                  <td>#partNo#</td>
                  <td>#description#</td>
            </TR>
            <CFSET headerrow = 0>
      </cfoutput>
</cfoutput>
Hi etherealz,

    <cfset lastProduct = "" />
    <cfoutput query="showProductComponents">
        <tr>
            <td>
                <cfif showComonents.partNo neq lastProduct>
                    #showComonents.partNo#
                <cfelse>
                    &nbsp;
                </cfif>
            </td>
            <td>
                <cfif showComonents.partNo neq lastProduct>
                    #showComonents.Name#
                <cfelse>
                    &nbsp;
                </cfif>
            </td>
            <td>#showComponents.partNo#</td>
            <td>#showComponents.description#</td>
        </tr>
        <cfset lastProduct = showComponents.PartNo />    
    </cfoutput>


Regards
Plucka
Avatar of etherealz

ASKER

plucka,

your codes don't work
<cfset lastProduct = "" />
<cfoutput query="showProductComponents">
    <tr>
        <cfif productNo neq lastProduct>
        <td>#partNo#</td>
        <td>#Name#</td>
        <cfelse>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </cfif>
        <td>#partNo#</td>
        <td>#partDescription#</td>
    </tr>
    <cfset lastProduct = productNo />    
</cfoutput>
didn't like my post?
etherealz,

I just notices your query name doesn't match your field names, try this as you don't need to specify query names within a cfoutput of a query.

    <cfset lastProduct = "" />
    <cfoutput query="showProductComponents">
        <tr>
            <td>
                <cfif partNo neq lastProduct>
                    #partNo#
                <cfelse>
                    &nbsp;
                </cfif>
            </td>
            <td>
                <cfif partNo neq lastProduct>
                    #Name#
                <cfelse>
                    &nbsp;
                </cfif>
            </td>
            <td>#partNo#</td>
            <td>#description#</td>
        </tr>
        <cfset lastProduct = PartNo />    
    </cfoutput>

Regards
Plucka
ASKER CERTIFIED SOLUTION
Avatar of dillusion13
dillusion13

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial