Renderring downloadable Link in DHTMLXGrid


One of our requirements is to allow users to download a file stored on the web server. We show information accessed from database in Dhtmx Grid. One of the cells in this grid needs to be the file download link.

On server side we are using Java connector API. One option I was thinking was to read information using JDBC result set and creating XML programatically. However, is there an option to achieve this functionality if we continue to use GridConnector.render_table(…) API? We tried it in HTML file using grid.setColTypes(“ro,ro,ro,link,ro”); but it did not work.

Any samples/suggetions are appreciated.


Answering my own quesiton…

This is possible by extending ConnectorBehavior class. Overriding beforeRender() method did the trick. Adding following code resulted in rendering a “Download” link in the grid.

	String s =  "Download^/FileLocation/TestFile.txt"  + "^_blank";
	data.set_value("<column name specified as the third parameter of render_table>", s);

Servlet responsible for calling render_table contains the followng code

GridConnector c = new GridConnector(conn, DBType.Oracle);
c.servlet(req, res);
c.event.attach(new AddLink()); // AddLink extends ConnectorBehavior
c.render_table("table", "id", "<columns>");

and in HTML