Quantcast
Viewing all articles
Browse latest Browse all 152999

Re: CFGRID. Specify query column in href attribute

You give no details of your code, which makes it difficult to explain. There are just too many factors to take into account. Instead, I will create an example that will illustrate.

 

It is all about a URL that will look like

 

http:// ... somePage.cfm?CFGRIDKEY=xyz

 

You have to keep an eye on the page of the URL ( somePage.cfm )  and on the value of the CFGRIDKEY ( xyz ). So, here we go.

 

First, create the following 3 test pages, besides the current page:

 

page1.cfm (contents: page 1)

page2.cfm (contents: page 2)

 

Next, create a test query containing 2 rows. The column downloadPage stores the relative URLs.

 

<cfset myQuery = QueryNew("eBookID, title, downloadPage", "integer, varchar, varchar")>

<cfset newRow = QueryAddRow(MyQuery, 2)>

<cfset temp = QuerySetCell(myQuery, "eBookID", 100, 1)>

<cfset temp = QuerySetCell(myQuery, "title", "Round the world in 80 days", 1)>

<cfset temp = QuerySetCell(myQuery, "downloadPage", "page1.cfm", 1)>

<cfset temp = QuerySetCell(myQuery, "eBookID", 200, 2)>

<cfset temp = QuerySetCell(myQuery, "title", "The Hitchhiker's Guide To The Galaxy", 2)>

<cfset temp = QuerySetCell(myQuery, "downloadPage", "page2.cfm", 2)>

 

<cfform action = "#CGI.SCRIPT_NAME#">

<cfgrid name = "bookGrid" query = "MyQuery"  href="downloadPage" width="500">

        <cfgridcolumn name = "eBookID" header = "ID">

        <cfgridcolumn name = "title" header = "Book Title"  width="300">

        <cfgridcolumn name = "downloadPage" header = "Page"  width="100">

    </cfgrid>

    <br>

    <cfinput type="submit" name="sbmt" value="Submit">

</cfform>

 

You will find that

 

1) Every grid entry is hyperlinked.

2) If you click on an entry in a particular row, the page of the URL will be the value of downloadPage for that row, and the value of the entry itself will be the value of CFGRIDKEY. For example, suppose you click on an ID of 200. That is in the second row, where the value of downloadpage is page2.cfm. Hence, the URL that will be opened will be

 

http:// ... page2.cfm?CFGRIDKEY=200

 

Suppose you next click on the first book title. That is in the first row, where the value of downloadpage is page1.cfm. Hence, the URL that will be opened will be

 

http:// ... page1.cfm?CFGRIDKEY=Round+the+world+in+80+days


Viewing all articles
Browse latest Browse all 152999

Trending Articles