0 Replies Latest reply on Feb 25, 2014 8:44 AM by tibay

    Using CFGrid with groupfield attibute displaying different column headers/data for each group

    tibay Level 1

      Hi,

       

      I'm trying to use CFGRID with groupfield attribute to display search results on a page.  The results data depending on the criteria being used by a user may result to many different product category.  Each product category has many different fields although there are some fields that are common to all product category.  So far I was able to display the result in group; however, it only displays the columns based on the first group.  Below is my code as my test.  There are 100+ fields, but have to simplify for testing purposes.

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <title>Untitled Document</title>

      </head>

       

      <body>

      <cfquery name="qGetProductsCategory" datasource="#application.DSN#">

          SELECT referenceunitid,referencesource, ID,orderyear, startupyear, fwclient,plantname,PlantCountry,UnitNo,

                      ProductId, Product,

                      CASE WHEN ProductId NOT IN (101600,101601,101602, 102100, 102157) THEN 101552

                      ELSE ProductId

                      END AS ProductCategoryId,

                      CASE WHEN ProductId=101600 THEN 'CNDR'

                      WHEN ProductId=101601 THEN 'FWH'

                      WHEN ProductId=102100 THEN 'GASIFIER'

                      WHEN ProductId=101602 THEN 'HRSG'

                      WHEN ProductId=102157 THEN 'SCRUBBER'

                      ELSE 'BOILERS'

                      END AS ProductCategory,

                      case when prifuel is not null then prifuel

                      else prifueltype

                      End as show_prifueldesc,

                      case when secfuel is not null then secfuel

                      else secfueltype

                      end as show_secfueldesc,

                      supplycompanies

             FROM vUnitsAllData

      </cfquery>

       

      <cfform name="gridform">

         

          <cfgrid

             name="ProductsGrid"

             format="HTML"

             query="qGetProductsCategory"

             collapsible="true"

             groupfield="ProductCategory">

            

              <cfif qGetProductsCategory.productcategory eq 'boilers'>

                <cfgridcolumn name="referenceunitid" header="ID" /> <!---tried to repeat many columns below but still did not work--->

                <cfgridcolumn name="referencesource" header="Ref Source" />

                <cfgridcolumn name="orderyear" header="Order Year" />

                <cfgridcolumn name="startupyear" header="Start-up Year" />

                <cfgridcolumn name="fwclient" header="Client" />

                <cfgridcolumn name="plantname" header="Plant Name" />

                <cfgridcolumn name="PlantCountry" header="Plant Country" />

                <cfgridcolumn name="unitno" header="Unit No" />

                <cfgridcolumn name="productid" header="ProductId" />

                <cfgridcolumn name="product" header="Product" />

                <cfgridcolumn name="productcategoryid" header="Product CategoryId" />

                <cfgridcolumn name="productcategory" header="Product Category" />

               <cfelseif qGetProductsCategory.productcategory eq 'HRSG'>

                          <cfgridcolumn name="referenceunitid" header="ID" />

                    <cfgridcolumn name="referencesource" header="Ref Source" />

                    <cfgridcolumn name="orderyear" header="Order Year" />

                    <cfgridcolumn name="startupyear" header="Start-up Year" />

                    <cfgridcolumn name="fwclient" header="Client" />

                    <cfgridcolumn name="plantname" header="Plant Name" />

                    <cfgridcolumn name="PlantCountry" header="Plant Country" />

                    <cfgridcolumn name="unitno" header="Unit No" />

                    <cfgridcolumn name="productid" header="ProductId" />

                    <cfgridcolumn name="product" header="Product" />

                    <cfgridcolumn name="productcategoryid" header="Product CategoryId" />

                    <cfgridcolumn name="productcategory" header="Product Category" />     

                    <cfgridcolumn name="show_prifueldesc" header="Primary Fuel" />

                    <cfgridcolumn name="show_secfueldesc" header="Secondary Fuel" />

               <cfelse> 

                      <cfgridcolumn name="referenceunitid" header="ID" />

                    <cfgridcolumn name="referencesource" header="Ref Source" />

                    <cfgridcolumn name="orderyear" header="Order Year" />

                    <cfgridcolumn name="startupyear" header="Start-up Year" />

                    <cfgridcolumn name="fwclient" header="Client" />

                    <cfgridcolumn name="plantname" header="Plant Name" />

                    <cfgridcolumn name="PlantCountry" header="Plant Country" />

                    <cfgridcolumn name="unitno" header="Unit No" />

                    <cfgridcolumn name="productid" header="ProductId" />

                    <cfgridcolumn name="product" header="Product" />

                    <cfgridcolumn name="productcategoryid" header="Product CategoryId" />

                    <cfgridcolumn name="productcategory" header="Product Category" />

                        <cfgridcolumn name="supplycompanies" header="Supplying Co" />

                      

                </cfif>

          </cfgrid>

       

      </cfform>

      </body>

      </html>

       

      What I would like to do, is depending on the product category, the column headers and data changes.  Is this possible in CF10?

       

      Thanks.