Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tommy on Jul 23, 2009 11:16
open dhtmlx forum
Link Behavior Inside Grid Cell

I have a grid with a column that's populated with links that when clicked should take you to a detail page for the record. It works fine if I just want to take the user away from the grid to the next page, or if I want to take the user to a blank window, but I'm trying to get it working with a popup window control inside Drupal 6 using Lightbox2. The way you launch a Lightbox2 window inside Drupal is to simply use the 'ref' tag within the anchor tag. So, outside of the grid, this link works as expected:

<a href="/somepage.php?id=009606" rel="lightframe">Click Me</a>

That creates a popup window with the page displayed inside it. But if I put that same link within a grid cell, the link works, but it won't launch the Lightbox frame. Instead, it takes you the result page directly and just doesn't launch the Lightbox. It seems that the 'ref' tag isn't having the desired effect. I've tried wrapping the cell data in <![CDATA[ ]]> and escaping the < and > characters, and I've tried setting the column type as 'link', but none of that seemed to make any difference.

You can see how LightBox2 works at http://www.stellapower.net/lightbox2

Thanks,
Tommy
Answer posted by dhxSupport on Jul 24, 2009 05:25
Probably issue occurs because of by the time of executing Lightbox2 script rows are not loaded to the grid yet. So there is no liks for the Lightbox2 sript to parse. Try to call Lightbox2 script only after all rows were loaded to the grid. You can define if all rows was loaded using 2nd parameter of load() method or "onXLE" event:
mygrid.load("grid.xml",function(){
   //all rows were loaded
})

mygrid.attachEvent("onXLE",function(){
   //all rows were loaded
})
Answer posted by Tommy on Jul 24, 2009 05:07
That makes perfect sense. I dug into the LightBox javascript a bit and found the function call that it attaches to the links when it parses. I attached that function to the cell links manually and it appears to work. Your way will probably ensure better forward compatibility. Lightbox also has an 'init' function that can be called to run its parser again, so I'll try calling that init function with your attachEvent. You guys are awesome.

Thanks,
Tommy