Displaying a database query in a grid using the CFGRID tag in ColdFusion

Readability

Displaying a database query in a grid using the CFGRID tag in ColdFusion

The fol­low­ing exam­ples show how you can dis­play a data­base query in a grid using the <CFGRID> and <CFFORM> tags in ColdFusion.




    SELECT A.*
    FROM ARTISTS A
    ORDER BY A.LASTNAME, A.FIRSTNAME






    
        
    



And the out­put of the <CFGRID> tag is as fol­lows:

By default the <CFGRID> tag dis­plays the grid as a Java applet. To dis­play the grid in a dif­fer­ent for­mat, set the format attribute, as seen in the fol­low­ing example:




    SELECT A.*
    FROM ARTISTS A
    ORDER BY A.LASTNAME, A.FIRSTNAME






    
        
    



And the out­put of the <CFGRID> tag is as fol­lows:

The following examples show how you can display a database query in a grid using the <CFGRID> and <CFFORM> tags in ColdFusion.

<html>
 
<cfquery name="getArtists" datasource="cfartgallery">
    SELECT A.*
    FROM ARTISTS A
    ORDER BY A.LASTNAME, A.FIRSTNAME
</cfquery>
 
<head>
</head>
<body style="padding:20px;">
 
    <cfform>
        <cfgrid name="myGrid" query="getArtists" />
    </cfform>
 
</body>
</html>

And the output of the <CFGRID> tag is as follows:

By default the <CFGRID> tag displays the grid as a Java applet. To display the grid in a different format, set the format attribute, as seen in the following example:

<html>
 
<cfquery name="getArtists" datasource="cfartgallery">
    SELECT A.*
    FROM ARTISTS A
    ORDER BY A.LASTNAME, A.FIRSTNAME
</cfquery>
 
<head>
</head>
<body style="padding:20px;">
 
    <cfform>
        <cfgrid name="myGrid" query="getArtists" format="html" />
    </cfform>
 
</body>
</html>

And the output of the <CFGRID> tag is as follows:

Leave a Reply

Your email address will not be published.