Critter’s Code

This is a picture of a bridge and a city. I like bridges and cities. They make me smile.

Archive for the ‘ColdFusion’ Category

Jun-29-2008

Old School ColdFusion - The bolt has been inked!

This has been on my ‘todo’ list for ages. I finally got around to getting it inked this evening.

The best ColdFusion logo of them all!

Old School ColdFusion Logo Tattoo

There was also a really cool article in the L.A. Times about my Seesmic tattoo.

Posted under ColdFusion, Seesmic, Social Media, Stuff
Jan-6-2008

Using ColdFusion.navigate() from within a cfgrid.

I had what seemed like a simple task. Load a query into an html cfgid. Users could then click on a row (record) and be taken to an edit/update page.

Piece of cake. I have done this many times before. Unfortunately, this was my first time attempting it with ColdFusion 8 and all it’s ajaxy goodness. CFGRIDCOLUMN has an ‘href’ attribute, but I was not able to fire off javascript from it, it would only execute regular links. I wanted my edit screen to open up below the grid in a CFDIV.

After much googling and mucking around, I was able to piece together the following. Which adds a click event to the cell.

   1:  addLinksforaTasks = function()
   2:  {
   3:      gTask = ColdFusion.Grid.getGridObject(‘agrid_tasks’);
   4:      cm = gTask.getColumnModel();
   5:      gTask.on(‘cellclick’,function(grid,rowIndex,columnIndex,e)
   6:      {
   7:      var unitID = ColdFusion.getElementValue(‘agrid_tasks’,‘taskform’,‘taskid’);
   8:      ColdFusion.navigate(‘atasks.cfm?action=edit&taskid=’+unitID,‘taskedit’);
   9:       }
  10:      )
  11:  }

The hardest part to figure out was how to get the id field value (in this case taskid).  It is such a simple thing that I was sure is used constantly, but I could not find much help on the web. Here is the function explained:  ColdFusion.getElementValue(’grid_name’,'form_name’,'columnid’). That gave me the taksid of the selected row in the grid.

To execute the function when the grid loads you need to add

<cfset ajaxOnLoad(’addLinksforaTasks’)> to the page containing the grid.

One other thing to note, if you are loading a grid into a CFDIV, you need to put all helper functions on the parent page. They do not seem to execute correctly if they are included on the page loaded into the CFDIV.

Anyway… hope that can help someone…

Posted under Ajax, ColdFusion, Samples