• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFGRID. Specify query column in href attribute

New Here ,
Sep 17, 2014 Sep 17, 2014

Copy link to clipboard

Copied

Extract from docs (about href attribute for cfgrid tag): URL or name of a query column that contains URLs to hyperlink each grid cell with.

This way not work. If i try to specify query column in href attribute like this: href="query_column_name", its did not work.
I want to specify a query column, which stores the URL's.

Where can I get an example of such a code?

Views

497

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2014 Sep 18, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 18, 2014 Sep 18, 2014

Copy link to clipboard

Copied

Thank you very much!

I understood.

Your code will work if cfgrid's attribute not specify (by default it is Applet).

In my case i tryed work with HTML format for cfgrid.
The same code with HTML format for cfgrid tag will not work:

<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 format="html" 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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2014 Sep 20, 2014

Copy link to clipboard

Copied

LATEST

I am hardly surprised that the HTML format of cfgrid fails. It is now generally accepted in the ColdFusion community that ColdFusion's User-Interface tags like cfform, cfgrid, cfdiv, cflayout, cfmap, and so on, are outdated, having lagged behind recent developments in Javascript, and are error-prone. For example, Ben Forta and Raymond Camden have voiced an opinion on the subject.

In fact, I would suggest you look for an alternative for the HTML grid, say, in jQuery. A good place to start looking is the site 'ColdFusion UI the Right Way'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation