Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sam on Jun 18, 2009 09:14
open dhtmlx forum
Links in dhtmlx Grid Tables

Hello,

I want to be able to add a link to a dhtmlxGrid page so that when the user clicks on the link it executes a javascript function I've defined in the Grid.jsp document.

I've set the mygrid.setColTypes = link for the column in question.

mygrid.setColTypes('link,ro,ro,ro,ro,ro,ro,ro,ro,ro');

I've defined the function within the grid.jsp file.

function editCell(table, id, ro) {
dhxWins = new dhtmlXWindows();
tbWindow = dhxWins.createWindow("tbWindow", 100, 100, 800, 600);
tbWindow.center();
tbWindow.show();
}

Here is an example of the cell data defined in the getGrid.xml document used for the mygrid.loadXML function

<cell>
<![CDATA[ Link^javascript:editCell("table","1",0);^_blank ]]>
</cell>


Could anyone help with this? I suspect it is an issue with the format of the xml file. Any help would be appreciated.

Regards,

Sam
Answer posted by dhxSupport on Jun 18, 2009 10:07
Please make sure if you have attached dhtmlxgrid_excell_link.js to your page. If issue still occurs please provide us more detailed information.
Answer posted by Sam on Jun 19, 2009 01:25

Hello,

Yes, the dhtmlxgrid_excell_link.js file is included in the grid.jsp file I am using.  I have also included a list of the other dhtmlx files included.

Could this be an issue with the format of the xml file?

Any help would be appreciated.

Kind regards,

Sam

 

dhtmlx/dhtmlxgrid.css
dhtmlx/dhtmlxgrid_skins.css
dhtmlx/dhtmlxwindows.css
dhtmlx/skins/dhtmlxwindows_dhx_blue.css
dhtmlx/dhtmlxcommon.js
dhtmlx/dhtmlxgrid.js
dhtmlx/dhtmlxgridcell.js
dhtmlx/ext/dhtmlxgrid_srnd.js
dhtmlx/ext/dhtmlxgrid_filter.js
dhtmlx/excells/dhtmlxgrid_excell_link.js
dhtmlx/dhtmlxwindows.js

Answer posted by Alex (support) on Jun 19, 2009 05:38

Hello,

please, use _self instead of _blank

<cell>Link^javascript:editCell("table","1",0);^_self </cell>


Answer posted by Sam on Jun 19, 2009 06:42

Hello,

Thanks for getting back to me.  I've tried to use _self instead of _blank but I still get the same results i.e. a blank window opens with javascript:editCell("table","2",0); in the address bar.

Aha, success!!!!

The url and target fields are non mandatory so I've added the javascript call as a html link in the name parameter of the .xml file

<![CDATA[ <a href='javascript:editCell("TABLE","2",0);'>Link</a>^^_self   ]]>

This includes the text Link as a hyperlink in the column, once clicked on it executes the js function.

Many thanks for your support with this.

Kind regards,

Sam